added check if failed to get api key