added destroy event handling