minor fixes in js
fixed the bug of overwriting name