for the lender or any other factor not directly related to a decline in the value of the taxi medallion or to the financial condition of the taxpayer. (D) Ordering rule If any loan is discharged, in whole or in part, and only a portion of such loan is qualified taxi medallion indebtedness, subsection (a)(1)(F) shall apply only to so much of the amount discharged as exceeds the amount of the loan (as determined immediately before such discharge) which is not qualified taxi medallion indebtedness. . (c) Conforming amendments (1) Section 108(a)(2) of such Code is amended by adding at the end the following new subparagraph: (D) Taxi medallion exclusion takes precedence over insolvency exclusion unless elected otherwise Paragraph (1)(B) shall not apply to a discharge to which paragraph (1)(F) applies unless the taxpayer elects to apply paragraph (1)(B) in lieu of paragraph (1)(F). . (d) Effective date The amendments made by this section shall apply to discharges of indebtedness after December 31, 2016.