Updated handleEvent() to match code in video