corrected and improved paging