added some group logic