Fixed an error in the error checking.