Intramolecular nucleophilic substitution