be more defensive in API usage