One of the most frequent real estate questions I get asked is about prepaying mortgages. There’s a lot of push and pull in the minds of many homeowners when it comes to deciding between prepaying their mortgages and investing that money elsewhere.

Most of the time, prepaying your mortgage is a perfectly good and reasonable idea. You will save thousands—if not tens of thousands—of dollars in interest, shorten the length of the loan, increase the equity in your home, and own it outright sooner. This is a guaranteed return on your investment in real dollars, so you cannot go wrong.

But, of course, it’s not as simple as that. There are a variety of personal factors—including how much money you owe, the type of mortgage you have, your interest rate, your other savings and investments, your debts, and even your age—that can influence just how good an investment prepaying your house will be versus investing elsewhere. So start with the basics.

Do you have any debt? If you are carrying any consumer debt through credit cards, auto loans, school loans, or medical bills, put your extra money toward paying off debt.

Do you have an emergency savings account? Because any money you invest in your home is not available to you unless you take out a home equity loan, you need to have easily accessible liquid assets in a savings account. You should have at least three months’ worth of income saved—and with today’s unstable job market, you really should have closer to a year’s worth.

Is your retirement on track? Before you put an extra dime in your home, you should have a retirement plan and be on track with your retirement savings goals. That means contributing the maximum amount to your 401(k), contributing up to the maximum in your Roth IRA (if you have one), and/or creating a separate savings plan that will line up with your retirement goals.

Where else do you want to see your money go? I’m talking about college for your kids, footing the bill for a wedding, paying for a big family vacation, or making sure you’re covered for any upcoming or ongoing medical bills. After all, this is extra cash you have on hand, so what are your priorities? Do you want your kids to graduate with minimal to no student loans? Have you been dying to take that honeymoon you never had to Hawaii?

After you’ve made all these considerations and you still have some extra cash to invest, then you have a decision to make: Should you prepay your mortgage or invest?

Today’s historically low interest rates, volatile stock market, and depressed housing market make the question even trickier. You need to weigh the pros and cons of each option.

Lower interest rates mean less savings, so if you have a 4 percent interest rate instead of an 8 percent rate, you’re not saving as much money over the long term if you prepay your mortgage. But you’re certainly making more money than letting that money sit in a savings account, where it will earn virtually no interest these days.

Investing in the stock market is still risky, and while you may earn more money, you also risk losing more money as well. Additionally, investing in property may be a sound long-term investment, but the short-term housing market is still on shaky ground.

If investing makes the most sense to you, find an investment that will pay more than what you will save in interest. This means if you have a mortgage rate of about 6.25 percent, and you take into consideration your mortgage interest deduction on your taxes, you’re really looking for an investment that will yield you more than 8 percent per year in order to get the same post-tax bang for your buck. Keep in mind that you may also have to pay capital gains taxes.

If you can find that investment deal and you are a bit more of a risk-taker, then consider investing long-term. And there’s always the split option—put half your extra money in your home and half in investments.

[amazon_link asins=’B00OLHIJ42,B012TH34DQ,B001R1Q0OG’ template=’ProductCarousel’ store=’thinkglink-20′ marketplace=’US’ link_id=’2453db15-31ef-11e8-bc2d-e3c376a7eaed’]