everything works but state machine