improved error message detection