fixes to query