Added new feature: attaching event handlers on register method