added code for when there's a tie