Add AngularJS script
Refactor the code