converted to AngularJS