Improved js functionality