fix setQuery function, should be using cmd.encode instead of name