refactored controllers and directive to inherit from Scope type