fixes pageNumber loop