     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()

    //MARK: IBAction(s)
    
    @IBAction func touchDigit(_ sender: UIButton) {
        let digit = sender.currentTitle!
        
        if userIsInTheMiddleOfTyping {
            let textCurrentlyInDisplay = display.text!
            
            if digit == "." && (textCurrentlyInDisplay.range(of: ".") != nil) {
                return

    //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
        } 
