better handling of error messages