Angularjs refactoring

Following AngularJS guidelines by @johnpapa's https://github.com/johnpapa/angularjs-styleguide