fixing javascript bugs