now with statemachine and ui, works