Look at the
'if ... else ...'
examples I gave you of different tests
and branching to different sections
by set / reset of 'flag' values
and see if you can code the exact solution that you wish?
If you get stuck ...
take a deep breath and 'think'
If ( condition is true ) do this
else do that
and try again ...
and if still stuck ... show the code you tried.