more robust error handling.