Fix a nil check issue with empty groups