transmission shifting too early at 40 mph it already at gear 4
Without knowing what type of vehicle, I can only provide you with probable causes. These probable causes cover both vacuum and electronically controlled transmissions. The shift cable can be out of adjustment or broken. An improperly functioning vacuum modulator can cause incorrect shift patterns. A faulty transmission control module can also cause erratic shifting. Internal faults in the transmission such as a bad valve body or conductor plat can effect shifting as can something as basic as low transmission fluid level.
It may be best to have a local transmission specialist inspect your vehicle.