Update main script to handle the network going down.
Update main script with refactored code. Props to @duonoid.