fixed init and event handling