refactored paging control