Working code with some tests - need to do tiebreaking yet