Make code event-driven