improve network_utils.py functions