minor bug fix for query