pagination working but buggy