fix some damn bugs in js