Workflow engine as function