added possibility of a tie

also some slight refactoring