Fix bad use of error checking