Refactored $rootScope to a service