Added checking for internet connection.