pagination refactoring