implementing event querying