moved api calls away from factory