added another check for api key = None