directive refactoring to remove dom from model definition