fix connection attempt loop