fixes bug in pagination