You can then set `meta = None` outside the loop, and set `meta['next_page_number'] == params['page_number']` as the loop invariant.