add priority to groups and use it to handle group conflicts