Synthesis of heterylamines