refactor angularjs