Rework of directive to use a service