Refactored code into element directives, not working yet