Edinburgh swept past Castres in the European Champions Cup to secure their place in the last 16.
The French side led at the break through tries from Josaia Raisuqe, Adrien Seguret and Wilfrid Hounkpatin.
Edinburgh had crossed through Dave Cherry and Bill Mata.
Mike Blair's side were much improved after the break. Tries from Cammy Hutchison and Ben Vellacott ensured a bonus point, before two Blair Kinghorn penalties wrapped up the win.
Edinburgh started well and deservedly took the lead when Cherry blasted his way over from the back of a rolling maul, but Castres took advantage of some ill-discipline to turn things around.
After Kinghorn was sin-binned for cynically slowing the play down, Raisuqe got on the end of Benjamin Urdapilleta's grubber kick to dot down, and shortly after Seguret stepped past Charlie Shiel to score under the posts.
A powerful carry from Mata drew Edinburgh level, but Hounkpatin's score on the stroke of half-time gave Castres the lead at the break.
Whatever Blair said to his side in the sheds did the trick. Their discipline improved no end, and they shored up defensively, keeping the French outfit scoreless in the second half.
In attack, Hutchison wasn't held in the tackle and caught Castres napping to score under the posts, before an excellent individual try from Vellacott put Edinburgh in front, and secured a bonus-point win.
Two late penalty goals from Kinghorn put the icing on the cake, and takes Edinburgh through to the knockout stages of the competition.
Line-ups
Castres: Larregain, Laveau, Botitu, Seguret, Palis, Urdapilleta, Doubrere; Walcker, Barlot, Hounkpatin, Nakarawa, Hannoyer, Cope, Raisuqe, Ben-Nicholas.
Replacements: Colonna, Tierney, Azar, Pieterse, Staniforth, Kornath, Arata Perrone, Cocagi.
Edinburgh: Immelman, Blain, Bennett, Hutchison, Kinghorn, Savala, Shiel, Schoeman, Cherry, Nel, Sykes, Gilchrist, Skinner, Ritchie, Mata.
Replacements: Cruse, Auterac, Atalifo, Hodgson, Haining, Vellacott, Scott, Sweeney.