             let xml = SWXMLHash.parse(data!)
             
             do {
-                fetchedInputRate = try xml["query"]["results"]["rate"].withAttr("id", "USD" + self.inputCurrency.code)["Rate"].element!.text!
-                fetchedOutputRate = try xml["query"]["results"]["rate"].withAttr("id", "USD" + self.outputCurrency.code)["Rate"].element!.text!
+                fetchedInputRate = try xml["query"]["results"]["rate"].withAttr("id", "USD" + currentInputCurrency)["Rate"].element!.text!
+                fetchedOutputRate = try xml["query"]["results"]["rate"].withAttr("id", "USD" + currentOutputCurrency)["Rate"].element!.text!
             } catch {
                 print("Error fetching currencies: \(error)")
                 hideActivityIndicator()

            
            // CoreData fetching.
            let inputFetch = NSFetchRequest(entityName: "Currency")
            let inputPredicate = NSPredicate(format: "%K == %@", "code", self.inputCurrency.code)
            inputFetch.predicate = inputPredicate
            inputFetch.fetchLimit = 2
            let outputFetch = NSFetchRequest(entityName: "Currency")
            let outputPredicate = NSPredicate(format: "%K == %@", "code", self.outputCurrency.code)
            outputFetch.predicate = outputPredicate
            outputFetch.fetchLimit = 1
            

            
            // Update UI on main thread.
            dispatch_async(dispatch_get_main_queue()) {
                NSNotificationCenter.defaultCenter().postNotificationName("CoinUpdatedNotification", object: nil, userInfo: ["currencyCode": currentInputCurrency, "currencyRate": fetchedInputRate])
                NSNotificationCenter.defaultCenter().postNotificationName("CoinUpdatedNotification", object: nil, userInfo: ["currencyCode": currentOutputCurrency, "currencyRate": fetchedOutputRate])
                print("Updated input and output currency rates.")
            }
            
