bugfix for query