Relocated the paging logic