detect event type and cast data appropriately