calculate paging