Refactored Code to make use of AngularJS ng-repeat directive