Update generate.js

Fixed bug