Added bestTie() function