Refactor, functions.recognizeWords, used in javascript