Fourth assignment, implement a query engine