fixed error on error checking