complex event processing code