fix pagination bugs