Steve constructs an automatic door latch as shown in the figure. When the switch is closed, the electromagnet attracts the door latch toward itself and the door can be opened. When the switch is opened again, the door latch comes back to its original position using the spring attached between the core of the electromagnet and the door latch.
Steve can improve the structure of the automatic door latch by