Changed incorrect logic for counting mean pairs per character