ensure error message correct, and add extra debug output