Fix bug that occurs in cases of tie