fix some case when the generation failed