What you have implemented can be categorized as a "state machine", or "workflow".
in reply to [SOLVED] possible to repeat if statement?
More formal implementations of this are "data-driven", which means that each STATE and CONDITION combination drives you to either a new STATE or ACTION.
All this is defined in a single data-structure (or "rule" type file).
If you can restructure your program around this idea, it will become more stable, and extensible.
However- you pay the up-front cost in engine implementation, and having to consider every STATE/CONDITION combination.
There are several modules that can help - I don't have sufficient experience with them to advise. Search on the keywords "state machine", or "workflow".
"I'm fairly sure if they took porn off the Internet, there'd only be one website left, and it'd be called 'Bring Back the Porn!'"
-- Dr. Cox, Scrubs