Fixing infinite loop bug

Fixed infinite loop bug in PaginatedResource