Fix event handler bug