Is Maryland Pension Exclusion Calculation correct?

I am not expert on the Maryland Pension Exclusion Calculation for those filling Maryland state taxes, but per the link below at one point it was done wrong - I got a letter from the IRS for 2017 about it, about a year ago. Is anyone who really understands how this exclusion works, able to verify that this year the calculation is correct? Thanks!

 

https://ttlc.intuit.com/community/retirement/discussion/i-think-maryland-pension-exclusion-calculati...