improved network check logic