added better get_ip() function