More refactoring with custom directives