angularjs refactored