Fixed bug in pagination