Minor error checking fix