If you post a code snippet, ALWAYS USE CODE TAGS:
How to use code tags: Using code tags properly
You may edit your post above.
This is my position on finite state machines (FSMs):
I’m kind of more of a “get it working first” guy.
Your mileage may vary.