Here's how to avoid a capital gains tax deduction.