Refactoring directives and pagination