put event handlers into an initialization function