Fix possible error in getNumberOfWords()