checkWord function