added support for custom event-based code