working on the statemachine code a bit