implement setQuery function