fix query logic. refs #1460
update query
Merge pull request #1462 from craigh/queryfix

fix query logic. refs #1460