Implemented tie-breaking algorithm.