Add proper event handling