Improved js generation