fix query engine