used non-deprecated methods for attaching event handlers