Congratulations, you've reinvented the wheel!
What you're doing is a variation of what yhfung came up with back in March:
http://www.obitalk.com/forum/index.php?topic=320.msg2901#msg2901A much cleaner version of a general purpose dialing scheme is:
Voice Services -> OBiTALK Service -> InboundCallRoute:
{(Mcot)>(Mpli):pli},{(Mcot)>(<*1:>(Msp1)):sp1},{(Mcot)>(<*2:>(Msp2)):sp2},{(Mcot)>(<*8:>(Mli)):li},
{(Mcot)>(<*9:>(Mpp)):pp},{(Mcot)>(<**1:>(Msp1)):sp1},{(Mcot)>(<**2:>(Msp2)):sp2},
{(Mcot)>(<**8:>(Mli)):li},{(Mcot)>(<**9:>(Mpp)):pp},{(Mcot):aa},{ph}
Note: Replace pli above with your PrimaryLine trunk name (sp1,sp2,li,pp,tg1) as the OBi won't.
User Settings -> User Defined Digit Maps -> User Defined Digit Mapx:
Label : cot
DigitMap : (290aaaaaa|290bbbbbb|290cccccc|290dddddd|290eeeeee)
This should allow any OBiON application listed in the 'cot' User Defined DigitMap to call out the desired trunk using single-stage dialing:
[number] through the OBi defined as the OBiON gateway (using PrimaryLine)
[**n + number] through the OBi defined as the OBiON gateway (using **n)
[<Speed Dial> + **n + number] through the OBi gateway defined in <Speed Dial> (using **n)
There's no security issues as only OBi numbers defined in 'cot' can make calls. Everyone else goes to the PHONE Port.