refactors to a directive