The gerund requires the SAME subject as the main verb. If subjects differ, use a subordinate clause (mentre/quando/perché/sebbene) instead of a gerund.
Gerund vs. Infinitive — Choosing the Right Form1 / 10
'Avendo già visitato Roma, abbiamo deciso di andare a Firenze.' Is this correct?