pageing, sorting refactoring