Fixed a bug in the word checking algorithm.