 }
 
 enum CalculatorState {
-    case oneOperand(operand: Double, screen: String)
-    case oneOperandAndOperator(operand: Double, operator: Operator, screen: String, lastCommandIsOperator: Bool)
+    case oneOperand(screen: String)
+    case oneOperandAndOperator(operand: Double, operator: Operator)
+    case twoOperandsAndOperator(operand: Double, operator: Operator, screen: String)
 }
 
 extension CalculatorState {
-    static let initial = CalculatorState.oneOperand(operand: 0.0, screen: "0")
+    static let initial = CalculatorState.oneOperand(screen: "0")
 
     func mapScreen(transform: (String) -> String) -> CalculatorState {
         switch self {
-        case let .oneOperand(operand, screen):
-            return .oneOperand(operand: operand, screen: transform(screen))
-        case let .oneOperandAndOperator(operand, operat, screen, _):
-            return .oneOperandAndOperator(operand: operand, operator: operat, screen: transform(screen), lastCommandIsOperator: false)
+        case let .oneOperand(screen):
+            return .oneOperand(screen: transform(screen))
+        case let .oneOperandAndOperator(operand, operat):
+            return .twoOperandsAndOperator(operand: operand, operator: operat, screen: transform("0"))
+        case let .twoOperandsAndOperator(operand, operat, screen):
+            return .twoOperandsAndOperator(operand: operand, operator: operat, screen: transform(screen))
         }
     }
 
     var screen: String {
         switch self {
-        case let .oneOperand(_, screen):
+        case let .oneOperand(screen):
             return screen
-        case let .oneOperandAndOperator(_, _, screen, _):
+        case .oneOperandAndOperator:
+            return "0"
+        case let .twoOperandsAndOperator(_, _, screen):
             return screen
         }
     }
 
     var sign: String {
         switch self {
-        case .oneOperand(_, _):
+        case .oneOperand:
             return ""
-        case let .oneOperandAndOperator(_, o, _, _):
+        case let .oneOperandAndOperator(_, o):
+            return o.sign
+        case let .twoOperandsAndOperator(_, o, _):
             return o.sign
         }
     }

        }
    }
}

            return state.mapScreen { "\((Double($0) ?? 0.0) / 100.0)" }
        case .operation(let o):
            switch state {
            case let .oneOperand(screen):
                return .oneOperandAndOperator(operand: screen.doubleValue, operator: o)
            case let .oneOperandAndOperator(operand, _):
                return .oneOperandAndOperator(operand: operand, operator: o)
            case let .twoOperandsAndOperator(operand, oldOperator, screen):
                return .twoOperandsAndOperator(operand: oldOperator.perform(operand, screen.doubleValue), operator: o, screen: "0")
            }
        case .equal:
            switch state {
            case let .twoOperandsAndOperator(operand, operat, screen):
                let result = operat.perform(operand, screen.doubleValue)
                return .oneOperand(screen: String(result))
            default:
                return state
            }
