Added checks for network connection