first version of query engine implementation