fixing javascript like a boss