fixed bug in JS