little refactoring in angular service