Improved the form and added the event handler