Audomatic Garage Door Close

About the goto alternative, you need to pick a good working logic and then decide, such as:

in the while loop, if certain condition is met, call an override function, which returns to the loop and the code continue to loop

or if with a different logic, you may decide to end the loop and then call the override function.

In any case, since the override code is pretty independent from other code, it can stay together as a function you can call.

It's best if you start with a flow diagram to specify how the program will run, and then write the code according to the flow diagram.