Check connection before trying to access it