bugfix on query