Improve the JS code.