event processing code for demo