Mechanism of the Gif-Barton type alkane functionalization by halide and pseudohalide ions