refactor dns lookup