checking Internet connection before trying to connect to it