Corrected JavaScript errors