put event handlers into initialization function