fix errors when query term not in dictionary