Fix bug in JS