Refactored to use directives and filters