I am learning about relays and to practice what I have learned I have decided to make a small electric gate using the following method. I am making a circuit to control the opening and closing of the gate with three push buttons and two limit switches. Pushbutton S1 opens the gate, S2 closes it, S3 is an emergency stop pushbutton, FCI1 is the left limit switch and FCD1 is the right limit switch. Everything works fine, but there is a problem, if the motor is turning in one direction and I press the push button to turn the motor in the other direction, the motor stops (it should keep turning until it reaches the limit switch or S3 is pressed). How can I do so that when it turns in one direction, no matter if it is given the order to turn in the other direction, it keeps turning until it reaches the limit switch or when S3 is pressed (as far as possible without using another relay)?
Circuit:

PS: Sorry if my English is not very good, I am not a native English speaker.
Circuit:

PS: Sorry if my English is not very good, I am not a native English speaker.