More robust error error handling