fixing bug in js