refactoring to instantiate rdt class in directive compile function