changed some functions to rootScope