fix a bug in pagination