Updated JS code