improve JavaScript generator