refacter workflow state