Refactor paginator