javascript bug fix