ported to angular.js