added check for connection status