Fix events query bug