Attached event handler to improved UX