refactor program workflow