cleaning event handler code