Like I said before, It was a very simple example, most logic would not be so simple and there are many ways to achieve this for example one shot rising so could only be set or reset on transition from low to high, or as I do, put any logic onto internal markers and use these in a block at end of program (or call block to outputs last) and use markers to drive outputs (I rarely set or reset outputs within the code blocks, it makes debugging easier, by putting all outputs in one call you can monitor and work back to find what is holding outputs on or what is stopping them from turning on) I have been programming for nearly 40 years as an OEM on many different platforms.