cleanup of get_network function