Event handler bug fix