checking connection inside loop

@kamuslhv, yes, I thought about this, I think we need separate task for this, let's discuss this today at the meeting.