some bugs in JS fixed