fix group logic