bug fix in JS --KW