Fix infinite loop when dealing with pagination.
Merge pull request #46 from andrewsomething/pagination_fix

Fix infinite loop when dealing with pagination.