Fixed bug in JS