Updated sample JS code