Modify how to iterate over wordIndex