Converted into AngularJS