corrected javascript