                 let imperialUnit = measurement.imperialValues.filter({(unit: Dictionary<String,String>) -> Bool in
                     return unit["name"] == name
                 })[0]
+                let defaultUnits = defaults.dictionary(forKey: self.dataLabel!.text!)
+                let siUnit = defaultUnits?["siUnit"] as! Dictionary<String, String>
+                defaults.set(["siUnit": siUnit, "imperialUnit": imperialUnit], forKey: self.dataLabel!.text!)
                 self.imperialButton.setTitle(name, for: .normal)
                 self.selectedImperialUnit = imperialUnit["abbreviation"]
                 triggerImperialValueChange()

        self.imperialButton.titleLabel?.textAlignment = NSTextAlignment.center
        if let measurement = dataObject {
            self.dataLabel!.text = measurement.header
            let siUnit = measurement.SIValues[0]
            let siText = siUnit["name"]
            self.siButton.setTitle(siText, for: .normal)
            selectedSiUnit = siUnit["abbreviation"]

            let imperialUnit = measurement.imperialValues[0]
            let imperialText = imperialUnit["name"]
            imperialButton.setTitle(imperialText, for: .normal)
            selectedImperialUnit = imperialUnit["abbreviation"]
        } else {
            self.dataLabel!.text = ""

    var selectedSiUnit: String? = nil
    var selectedImperialUnit: String? = nil
    var unitSelections: [Dictionary<String,String>]? = nil
    let defaults: UserDefaults = UserDefaults.standard

    override func viewDidLoad() {
        super.viewDidLoad()
