# Flow's Collect Step Only Storing Most Recent Array

**URL:** <https://community.postman.com/t/flows-collect-step-only-storing-most-recent-array/74993>\
**Category:** Help Hub\
**Tags:** postman-flows\
**Created:** [February 6, 2025, 11:38am UTC](https://community.postman.com/t/flows-collect-step-only-storing-most-recent-array/74993 "2025-02-06T11:38:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![anotioneer](https://avatars.discourse-cdn.com/v4/letter/a/b5a626/32.png) [@anotioneer](https://community.postman.com/u/anotioneer)\
**Post date:** [February 6, 2025, 11:38am UTC](https://community.postman.com/t/flows-collect-step-only-storing-most-recent-array/74993/1 "2025-02-06T11:38:44Z")

</div>

I’m creating a flow which will paginate through a list of Notion page search results and count the number of results. The pagination part is working correctly but I’m trying to store the results in a Collect step and it’s only storing the latest array that was passed to it -

 ![CleanShot 2025-02-06 at 11.35.55@2x](https://us1.discourse-cdn.com/getpostman/original/3X/9/1/910886651e3c07ea66d0224e4246587a0c511000.png)

The contents of `body.results` is an array so I was expecting the Collect step to store each array of results and output the combined array once it finished.

Does the collect step only work in a For loop (I’m using [this approach](https://www.youtube.com/watch?v=6VLquc7A56Y) to create a loop instead) or am I doing something else wrong here?

---

<div class="post-metadata">

**Author:** ![flows-daniel](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/flows-daniel/32/25516_2.png) [@flows-daniel](https://community.postman.com/u/flows-daniel)\
**Post date:** [February 6, 2025, 8:40pm UTC](https://community.postman.com/t/flows-collect-step-only-storing-most-recent-array/74993/2 "2025-02-06T20:40:11Z")

</div>

Hi @anotioneer

The collect block only works with a for block to collect results.

The solution is to accumulate the values in an evaluate block prior to your if block and then output the results.

See below:

 ![Screenshot 2025-02-06 at 12.35.01 PM](https://us1.discourse-cdn.com/getpostman/original/3X/6/2/62f7a7794875c84134906140472c1b5367a62296.png)

1. In the evaluate block, we’re appending the first result to an empty list (in this case it should be appended to the first API call you make that has the first page instead of an empty list.
2. In the if block, if there are more results, we re-trigger the send request block and use the list as the input to the evaluate block on the next iteration so that the values accumulate.
3. otherwise once there are no more pages, display the accumulated list.

Let me know if you run into any issues with this approach.
