improved the directive and made it more generic