Refactored controllers to use this when attaching functions insetad of  and other refactoring work