adding event handlers and moving die call there