Added check on connection status