Refactor directive to be an element