some refactoring, making pagination make sense