Changed purityHelper to count from topic-i instead of pattern-i