Completed getWinner function