Updated event handler addition code.