Updated to use $rootScope