     private var brain = CalculatorBrain()
     private var userIsInTheMiddleOfTyping = false
     
-    var iPhoneModel: Device {
-        get {
-            return Device()
-        }
+    private var iPhoneModel: Device {
+        return Device.current
     }
     
-    var displayValue: Double {
+    private var displayValue: Double {
         get {
-            return Double(display.text!)!
+            return Double(display.text ?? "") ?? Double.nan
         }
         set {
             let tmp = String(newValue).removeAfterPointIfZero()

    }
    
    @IBAction func performOperation(_ sender: UIButton) {
        
        if userIsInTheMiddleOfTyping {
            brain.setOperand(displayValue)
            userIsInTheMiddleOfTyping = false

    //MARK: UIVIew Delegate
    
    override func viewDidLoad() {
        // round the corners of the calculator on iPhone X
        if iPhoneModel == .iPhoneX || iPhoneModel == .simulator(.iPhoneX) {
            cornerView.layer.cornerRadius = 35
            cornerView.layer.masksToBounds = true
        } 
