refactoring to use directive