Finish refactor into directive