Refactor workflow to workflowrule