Written the event handler for the actual machine