checking connection inside loop