updated JS code