Fix issue where paged results was entering an
infinite loop based on the results of an earlier
query instead of using the latest one.

Introducing an intermediate variable inside the
scope of the until.