added initial group detection (it works! yay!)