fixed bug with query generator