Updated error checking method.