add hostname resolution from ip address, refactor