corrected js code