Caring for an elderly relative can be rewarding, but incredibly difficult as well as expensive. However, it may be possible to recoup some of the costs through income tax savings.

There are three general approaches to tax savings on elder care costs declaring your elderly relative as a dependent to receive an exemption, taking medical deductions that can be itemized, and claiming a dependent care credit that can be subtracted directly from the taxes you owe.

First, you must determine if your elderly relative qualifies as a dependent. Full details are listed in IRS Publication 501, “Exemptions, Standard Deductions, and Filing Information,” but the primary criteria are that they must be a relative, you must be providing over half of their support, and their gross 2017 income must be less than $4,050.

The definition of relatives includes stepparents and in-laws. They do not have to live with you to meet the requirement as a dependent, but deductions change if they are in a long-term care facility or nursing home.

To calculate support levels and income requirements, you must consider income sources from your elderly relative such as dividends from investments, although Social Security income is excluded. If they live with you, you must consider percentages of your mortgage, utilities, transportation, and other household expenses when calculating your economic support.

If you determine that your relative can be claimed as a dependent, you can add them as an exemption on your tax forms. The Tax Cuts and Jobs Act of 2017 (TCJA) has done away with personal exemptions for tax years 2018-2025, so take it now while you can. If your relative can’t be claimed, you have two possible avenues:

Multiple Support If more than one person is supporting the elderly relative and the group covers more than 50% of the costs, one of you can claim your elderly relative as a dependent if they contribute at least 10% of the support. The others must sign a form agreeing not to also claim the relative as a dependent for that year.

Itemized Medical Expenses You can still deduct medical and dental expenses even when your elderly relative is not a dependent, if all other criteria but the income requirement is met. There is a large list of potential medical expenses, including insurance premiums and elements of nursing and long-term care. IRS Publication 502, “Medical and Dental Expenses,” contains a large list of qualifying medical expenses, including insurance premiums and elements of nursing and long-term care.

You can only deduct these expenses if the costs exceed 7.5% of your Adjusted Gross Income (AGI). The TCJA lowered this threshold from 10% for tax years 2017 and 2018, but it goes back up to 10%, effective tax year 2019.

The Dependent Care Credit allows tax breaks on home-care and elder-care costs that are necessary for you and your spouse to be able to work. The credit covers up to 35% of expenses with a $3,000 expense limit (thus $1,050 maximum credit). It can cover expenses allowing you to look for work, but to claim the credit, you will need to have earned income during the year (this also applies to your spouse).

These expenses cannot be devoted to both medical care deductions and the Dependent Care Credit; however, you can devote home-care costs toward the Dependent Care Credit and other medical expenses toward the medical-care deductions. Without the home-care costs included in medical deductions, you may not reach the 10% criteria. Do the math to see which approach works best for you.

“The Dependent Care Credit can be very valuable. It was actually on the potential chopping block as far as the recent tax reform, but it survived,” reports Betterment Head of Tax Eric Bronnenkant. “Let’s say you have two kids, and let’s say your employer offers a dependent-care account, you’re able to contribute up to $5,000 tax-free through your employer and get reimbursed for dependent-care expenses tax-free. And then on top of that, you also get another $200 credit effectively for another $1,000 worth of expenses.”

Elder care situations can be complex, and it is usually wise to consult with a tax professional. With some assistance, you can find the best path to help you simultaneously care for your elderly relative and save money a win-win situation.