Started with refactoring for Angular.JS