refactor to cleanup hasMore loop.