I'm not sure if I got this right, but wouldn't it make sense to check for Count reaching max results here and calling stop_fold instead of ack_keys in that case here? It seems we are waiting for the next batch of results to check the count.