correct the paging function