The mechanism of rearrangement of chorismic acid and related compounds