Fixed a bug in pagination