updated code, found bug when the first group of scatter ranks do not perform scatter at all