Update main.py

added a crude fStateMachine function.