Optimized connection check