Added tally algorithm