Refactoring pagination model