Added function to check network connection