Corrected JS code