made api-discovery more robust