@trillbilly Write it out as a list, in English.

Do this,
Then do this,
If this, do this,
Otherwise do this
etc.
etc.

It might make it easier to figure out the flow of the program.