Corrected showPrevNext flag, Adjusted pageCount logic