moved bigram counting into swap function