can this be optimized, so get_ipv4() is only called once?