refactored statemachine to be an component close #24