Minor bug fix in query engine