Mechanistic study of copper-catalyzed intramolecular ortho-C-H activation/carbon-nitrogen and carbon-oxygen cyclizations