fix n-way ties (I think)