some bug fix when generate