more robust and faster way to get the ip address