fix connection conditional