Before the stock market collapse, many readers who could pay off mortgages put the money in the stock market instead.

They weren't stupid. Quite often their investment advisors told them to take the investment option. Their advisors, in turn, argued that paying 6 percent interest was smart when you were earning 20 percent. Even after the bear market, lots of people are still trying to answer the question, witness this e-mail from D.K.

"If I inherited $60,000 would it be better to leave it in an existing investment account or use it to pay off a 15 year $60,000 mortgage at 6.25 percent? The investment account is 80 percent mutual funds and 20 percent bonds earning 6 percent. I pay about 20 percent of my income in taxes.

This question involves interest expense avoidance (I hate owing people money), more money to invest in my company 401k plan, and peace of mind knowing my house is paid for--- I am within 8 years of retirement."

The answer: What you do depends on your age. In this case, go for the sure shot first. Follow with a lot of new investment.

Here's why. With a $60,000 mortgage you probably don't itemize your personal deductions. For most middle income Americans, the tax benefits of home ownership are minimal. The cost of borrowing is a flat 6.25 percent a year. It's very difficult to get that return investing. When you do, it's taxable income.

If your job is secure or if you have other savings, use the $60,000 inheritance to pay off the mortgage. Your non-deductible mortgage payments will decline by about $500 a month.

Put the same $500 a month into automatic 401k contributions. This will cut your taxable income by that amount, reducing your taxes. If you are in the 25 percent tax bracket, you could save $667 a month and still have the same spendable income.

If you are in the 15 percent tax bracket, you could save $588 a month and still have the same spendable income.

Here's the math. Right now, the inheritance and the mortgage cancel each other. One is a $60,000 asset. The other is a $60,000 debt. If you keep the $60,000 invested and it earns 9 percent, it will grow to $119,000 (excluding taxes) over the next 8 years. The balance due on your mortgage will decline to $35,000, leaving you a net gain of $85,000.

If you pay off the mortgage and use the liberated cash flow to increase your 401k plan contributions, a $588 monthly investment at 9 percent will grow to $82,200. A $667 monthly investment will grow to $93,000.

If you're certain that you will be in the 15 percent (or lower) tax bracket when you retire, paying off the mortgage and substituting higher 401k contributions is a slam-dunk. This is one of the reasons we should strive to enter retirement with no obligations.

Is there ever a time when it's better to invest than pay off a mortgage?

Yes. Suppose you are a younger person trying to decide between a 15-year mortgage and a 30-year mortgage. If you can afford to make the payments on a 15-year mortgage, should you pay it off in 15 years and then invest the same payment for 15 years? Or should you make payments on a 30-year mortgage and invest the payment difference every year for 30 years? Either way, we're committed to making the same monthly payments for 30 years.

Here's the math. If you borrow $100,000 at 5.5 percent for 15 years you'll have a monthly payment of $817.08, followed by another 15 years with monthly investments of $817.08.   If you borrow at 6.0 percent for 30 years you'll have a monthly payment of $599.55, leaving $217.53 to invest each month for 30 years. Either way, the mortgage will be paid off.

The difference will be what your investment account accumulates. Invest $817.08 for 15 years and it will accumulate to $309,187.75, if your return is 9 percent. Invest $217.53 for 30 years and it will accumulate to $398,241.56.

More important, the odds of getting that 9 percent return improve if you invest for 30 years. Historically, while investments in a large stock index produced 9 percent or greater returns in 41 of the 63 periods between 1926 and 2003, investments in a large stock index produced a 9 percent or greater return in 45 of the 47 thirty year investment periods.

If you're young, save and invest over the longest period possible. If you're older, go for the more certain return.