checkWord() function logic fix