added checks for network connection