Added tie-breaker logic