started refactoring of pagination