check for connection before toggling