Added a check for internet connection