working map/reduce on event queries