fixes to query utility