Pagination refactoring