         self.actualInterestPaid = 0
     }
 
-    func requiredMonthlyPayment() -> Float {
-      //FIXME: Highly unefficient
-        //    M = P[i(1+i)^n]/[(1+i)^n -1]
-        return (amount * ((monthlyInterestRate * (1 + monthlyInterestRate)^^months) / ((1 + monthlyInterestRate)^^months - 1)))
-    }
-
     func theoricalTotalInterestPaid() -> Float {
-        let totalPayment = requiredMonthlyPayment() * Float(months)
+        let totalPayment = requiredMonthlyPayment * Float(months)
         return totalPayment - amount;
     }
 }


extension Mortgage {
  func next(extraPayment: Float) -> MortgagePayment {
    let requiredPayment = requiredMonthlyPayment()
    if (requiredPayment > balance) {
      return MortgagePayment(principal: balance, interest: 0)
    }



let mortgage = Mortgage(amount: amount, years: durationInYears, yearlyInterestRate: interestRatePercentage)
print("Your monthly payment will be \(currencyFormatter.string(from: mortgage.requiredMonthlyPayment)) \n")


let totalInterestPaid = mortgage.theoricalTotalInterestPaid()
