update and improve getNextWord function