fixed bug with queries