improve js generation