main modified for join group. Jingyi