Fix reference error regarding event handling