Multiple DIDs through multiple SIP Trunks

[help] Looking for a clean way to configure routing for multiple DID per multiple SIP trunks. my carrier proposed something like this, but I find it over-engineered:

exten => s,1,Set(Var_TO=${SIP_HEADER(TO)})
exten => s,2,GotoIf($["${Var_TO}" = “”]?extension2,s,1:3)
exten => s,3,GotoIf($["${Var_TO}" = “”]?extension1,s,1:4)
exten => s,4,GotoIf($["${Var_TO}" = “sip:MYCCDID@”]?extension1,s,1:4)
exten => h,5,Macro(hangupcall)


If the To: header contains a direct in dialling number, you won’t end up on the s extension, but rather on the extension for that DID.