refactor dns lib