using angular directive to refactor