Refactoring in order to take advantage of the Angular.js Javascript framework.