Refactoring the pagination and improving the documentation