added disconnect and grouping logic