fix error in error checking