Better error condition handle.

Better error condition handle. Thx Kris to point it out