more complete handling of paging