better connection state parsing