fixing javascript bug