refactor dns stuff into separate file