stripped out old stuff ready to restart code
new code added, rework state model
check?
check2