ch07: implement query()