Query bugfix