bug fix in JS