fix invalid document