Corrected JavaScript