re-organize helper functions into angular service