Mechanism of the Wolff rearrangement