move handling of output events to functions