A combined experimental and theoretical investigation of the stereoselectivity in the synthesis of azahetrocyclic phosphonates