ported to AngularJS