     }
     
     @IBAction func onOperationTapped(_ sender: CalculatorButton) {
-        if calculator.currentValue == nil {
+        if calculator.solution != nil {
             calculator.previousValue = calculator.solution
         } else {
             calculator.previousValue = calculator.currentValue

        let inputText = sender.titleLabel!.text!
        let currentText = resultLabel.text!
        
        if currentText == zero || calculator.currentValue == nil {
            resultLabel.text = inputText
        } else {
            resultLabel.text = currentText.appending(inputText)

            calculator.previousValue = solution
        }
        
        clearOperationButtonHighlight()
    }
    
