Refactoring pagination module