Refactored the network script