fix bug in generate