     @IBOutlet weak var history: UILabel!
     @IBOutlet weak var display: UILabel!
     
-    var userInMiddleOfTypingNumber:Bool = false
+    var brain = CalculatorBrain()
     
-    var brain = CalculatorBrain()
+    var userIsTypingNumber:Bool = false
+    
+    // MARK: Add Digits, Floating Points and Operations Methods
     
     @IBAction func appendDigit(sender: UIButton) {
         if let digit = sender.currentTitle{
-            display.text = (userInMiddleOfTypingNumber ? display.text!+digit : digit)
-            userInMiddleOfTypingNumber=true
+            display.text = (userIsTypingNumber ? display.text!+digit : digit)
+            userIsTypingNumber=true
         }
     }
     
     @IBAction func appendFloatingPoint() {
         if display.text!.rangeOfString(".")==nil{
             display.text=display.text!+"."
-            userInMiddleOfTypingNumber=true
+            userIsTypingNumber=true
             historyValue = (historyValue ?? "") + "."
         }
     }
+    
+    @IBAction func posOperation(sender: UIButton) {
+        if let value = displayValue {
+            brain.pushOperand(value)
+            displayValue=0
+            pushOperation(sender)
+        }
+    }
+    
+    @IBAction func preOperation(sender: UIButton) {
+        pushOperation(sender)
+    }
+    
+    func pushOperation(sender: UIButton){
+        if let operation=sender.currentTitle{
+            brain.pushOperation(operation)
+        }
+    }
+    
+    // MARK: Enter Method
+    
+    @IBAction func enter() {
+        if(userIsTypingNumber){
+            userIsTypingNumber=false
+            if let value = displayValue {
+                brain.pushOperand(value)
+            }
+        }
+        if let result=brain.evaluate(){
+            displayValue=result
+            historyValue = (historyValue ?? "") + "="
+        }
+        else{
+            display.text = "Error"
+            brain.clearOpStack()
+        }
+    }
+    
+    // MARK: Clear Methods
     
     @IBAction func undoDigit() {
         if let displayString = display.text, let historyString = historyValue{

        }
    }
    
    func clearDisplayAndHistory(){
        displayValue=0
        userInMiddleOfTypingNumber=false
        historyValue = ""
    }
    
    @IBAction func clear(sender: UIButton) {
        clearDisplayAndHistory()
        brain.clearOpStack()
    }
    
    @IBAction func enter() {
        if(userInMiddleOfTypingNumber){
            userInMiddleOfTypingNumber=false
            if let value = displayValue {
                brain.pushOperand(value)
            }
        }
        if let result=brain.evaluate(){
            displayValue=result
            historyValue = (historyValue ?? "") + "="
        }
        else{
            display.text = "Error"
            brain.clearOpStack()
        }
    }
    
    @IBAction func posOperation(sender: UIButton) {
        if let operation=sender.currentTitle{
            if let value = displayValue {
                brain.pushOperand(value)
            }
            brain.pushOperation(operation)
            displayValue=0
        }
    }
    
    @IBAction func preOperation(sender: UIButton) {
        if let operation=sender.currentTitle{
            brain.pushOperation(operation)
        }
    }
    
    var displayValue:Double?{
        get{

                    display.text="\(newValue!)"
                }
            }
            userIsTypingNumber=false
        }
    }
    
