Modify paginationMaker algorithm