Make q variables local to function scope

In execute and nestedExecute functions, changed q variable to "var q" so that it's not in the global scope