implement function addQuery