added a version that counts words