fixed bug in generate.js