[minor] Added a connection counter a slight variable re-ordering