refactoring of everything with angularJS