add flow-based state functionality