A friend once told me his mortgage payment was the same as his monthly rent, so buying a home was a “no-brainer.” Problem is, that payment didn’t include the cost of taxes and insurance over time, which can skew the numbers quite a bit. It’s not to say he made the wrong decision; that’s just not all the math.

Buying a home is a big decision, so don’t limit yourself to the obvious factors when you crunch the numbers. Most people think about home price, the cost of renting, the mortgage payment, interest rate, and maybe even higher maintenance and utility bills. Those are all important, but here are some major, additional costs to consider:

Taxes and insurance: What is your total mortgage payment: principal, interest, taxes, and insurance (PITI)? If you’re paying for mortgage insurance, add that in, too. Here’s a calculator to help. Taxes and insurance can add up quite a bit over the years, so you want to add that into your calculation.

Tax breaks: Some states might offer credits for renters, but homeowner’s get the biggest tax breaks. This calculator can help you estimate how much you’ll get.

The opportunity cost of your taxes and insurance: What kind of long-term return could you get if you invested this money instead, in the stock market, a CD, or even a “high interest” savings account?

The opportunity cost of your down payment: Same story here. How much of a return could you get if you invested that lump sum instead?

It’s silly to say buying or renting is always the best or worst decision, because the factors vary so widely depending on specific situations. Don’t just assume buying is bad because it’s been oversold. Do the math for yourself and consider the above factors to decide which is the best decision for you.