convert events to functions