completely fixed the pagination arithmetic

It took a whole day lol