Fixed problems in pagination