refactored to more match the style of angular.