Api service changed to a factory