added tiebreaker code - needs refactoring
merging with desktop version
merged