I’m remodeling a customer’s bathroom, which is a multi-step process. The bathroom had a very old and inefficient fan that needed to be replaced. When I explored the situation further it turned out that the exhaust fan was venting warm, moist air directly into the attic. This, of course, is a poor practice. See the photos below for how I remedied this problem.

Here is the old fan. You can see that it is in bad shape.
The old fan removed. You can see the exhaust vent. It was covered with insulation in the attic and the air had nowhere to go.
The frame for the new fan.
I used the existing wiring and added BX to make the connection easier.
I added a flexible duct and then went on the roof to add a vent. I placed the duct in the bathroom to make installation easier.
Since I was working solo I used bungie cords as a second set of hands.
The fan installed the right way.