Added type safe version of event handling