The problem is that this code is not respecting the user's specified "limit". Let's say a user specifies a limit of 40 items per request of a total of 200 items in the server; with this implementation I think each page won't have 40 items as requested (and I'm not sure if all 200 items will be returned).