Fix broken group comparison logic