fixed a bug in js