Refactor paginate_by_params