This seems inefficient, we look up the domain, resolve it to addresses, then, if there's at least one address, we re-do the look-up later (line 155).  Can't we finish here and be done with it?