made statemachine work