refactor paging