generation of event query functions