Added a check for internet connection, untested