refactoring angularjs code
update