handles possible api response.