Added a function to check for an internet connection