         gasStat.userId = user_id
         gasStat.carId = carPicker.selectedRowInComponent(0)
         _insertGasStat(gasStat)
+        self.updateTankRecord()
         updateButtonsAndRecords(false)
     }
     

    }
    
    @IBAction func pressedLogIt(sender: AnyObject){
        var miles = (milesTextField.text as NSString).floatValue
        var gallons = (gallonsTextField.text as NSString).floatValue
        var cost = (costTextField.text as NSString).floatValue

        self.bottomLabelsView.hidden = editing
        self.bottomLabelsView.opaque = editing
    }
    
    func updateTankRecord() {
        tankRecord.lastTank = NSNumber.init(double: mpg)
        if (tankRecord.bestTank.doubleValue < mpg)
        {
            tankRecord.bestTank = NSNumber.init(double: mpg)
        }
        var total = statCount.doubleValue * tankRecord.avgTank.doubleValue
        total = total + mpg
        var newAvg = total / (statCount.doubleValue + 1)
        tankRecord.avgTank = NSNumber.init(double: newAvg)
        bestTankLabel.text! = NSString(format: "Best Tank: %.2f", tankRecord.bestTank.doubleValue)
        avgTankLabel.text! = NSString(format: "Avg. Tank: %.2f", tankRecord.avgTank.doubleValue)
        lastTankLabel.text! = NSString(format: "last Tank: %.2f", tankRecord.lastTank.doubleValue)
        gasBillLabel.text! = NSString(format: "Gas Bill: $%.2f", 99.99)
        _insertTankRecord(tankRecord)
    }

}

