use AngularJS service instead of , slight code cleanup