Modify directive to take advantage of templating. Still need to fix format