started refactoring with angular.js