refactoring to move rootScope logic into services