Added code to check for internet connection