code refactoring for pager