fixing NameError: free variable 'searchTermSyntax' referenced before assignment in enclosing scope

Fixing NameError: free variable 'searchTermSyntax' referenced before
assignment in enclosing scope