fixed bug with page count going over the limit