Added check for network connection