finished adding stateflow logic