Refactoring with single_operation; add 3-operand case.