how about something like this (not knowing the exact syntax of the line - if it's a nickname or not):
if (services.X.net isin $1-) { go here }
if (X.gotdns.com isin $1-) { go there }
OR
if (services.X.net == $n) { go here }
if (X.gotdns.com == $n) { go there }
does that help?? Replace $n with $1, $2 etc