Rewrote the event handlers