Updated query for getting events