Walking away with a profit on your home sale is an exciting proposition. But there’s one thing that can suck the excitement right out of such a positive financial move:the threat of taxes on your investment gain — otherwise known as the dreaded capital gains tax.

Luckily, the Taxpayer Relief Act of 1997 helps many homeowners hold on to the gains earned on their home sale. Pre-1997, homeowners could only use a once-in-a-lifetime tax exemption of up to $125,000 on a home sale, or they would need to roll their earnings into the purchase of another home. Today the rules aren’t quite so stringent. As with all tax-related things, there are plenty of exceptions and loopholes to be aware of. So let’s break down a few misconceptions about capital gains and home sales.

Tax treatment: House flippers vs. homeowners

One common misconception when it comes to capital gains tax on real estate is that all home sales are treated equally. Unfortunately for house flippers, that’s simply not the case. To receive the best tax treatment on your gains, you must have used the home as your primary residence for two out of the five years preceding the sale. If the home was not used as a primary residence for the required time, profit on the sale is taxed as capital gains. However, for those who flip houses on an ongoing basis, homes are considered inventory instead of capital assets, and the profit earned is taxed as income. Long-term capital gains tax is 15% for most people, 20% for those in the top tax brackets. However, if the gains are taxed as  income, rates could range from 10% to 39.6% depending on the rest of your income. In addition, house flippers aren’t allowed to simply avoid the tax by rolling profits over into their next home purchase.

Exemption limits: Filing married vs. single

While the Taxpayer Relief Act did away with the once-in-a-lifetime tax exemption of $125,000, exemption limits haven’t completely fallen by the wayside. Now you can pocket up to $500,000 of each home sale profit tax-free if you’re married, or up to $250,000 if you’re single. But for some newly married couples, claiming this exemption can be a little tricky. If one person owned the house for the past two years, but their partner wasn’t added to the title until, say, the last two months, that’s OK. However, both parties must have lived in the residence for two years prior to the sale — even if only one was on the title before they were married. In addition, if one person sold a previous home within the last two years and cashed in on an exemption, the couple will have to wait until they are both out of that two-year window before pocketing any gains from their shared home.

Type of home: Primary residence vs. vacation home or rental property

If you aren’t flipping homes, but you do have a second home or a rental property you’d like to sell after living there for the required two years, it won’t be treated as a primary residence for tax purposes. Second homes and rental homes no longer receive the same tax shelter they did before a 2008 shift in the tax code — even if the home becomes your primary residence for a time. Instead, when tax time comes around, you will owe a prorated amount based on the number of years the property was rented out or used as a second home after 2008. If, for instance, you used your vacation home as your primary residence for five years starting in 2010, but you used it as a vacation home for 15 years before that, only 10% of the gains would be taxed: The two years post-2008 when it was used as a vacation home equals 10% of the total 20 years of homeownership. The rest of the profit wouldn’t be taxed as long as it fell within the exemption limits.

Profit: Large sale price vs. small sale price

Another common misconception is that the more a home sells for, the larger the tax bill will be. However, for tax purposes, what you owe doesn’t depend on the sale price — it’s based on how much profit you make from the sale. In fact, you could sell your home for $5 million and not owe a penny in taxes — as long as you didn’t make more than the allowed exemption amount on the sale.

Another important thing to note: Capital gains tax on real estate isn’t necessarily an all-or-nothing proposition. If you’re nearing the cap on exemptions, you could still qualify for a partial exemption — just be sure to consult a tax professional before you make any big moves.