fix bug in pagination