Finished paginate with refactoring