resolv - working version with code at wrong places