A novel method for heterocyclic amide–thioamide transformations