added tie breaker logic