Refactor with Angular.js