Refactored the paging system