refactoring - added global vars to $rootscope