Selling two primary homes in one year

 I know I did something stupid in what I did here, but I am trying to understand the tax law here. Long story short. My first house I have lived in for the past 14 years. I moved to change jobs and bought a new home in that location. Then sold my first home for a gain of ~100k. I bought the second home just to get me in the area of my new job. We found our hopefully forever home and bought it (Home three). We then sold home two all in the same year as we sold home one for a gain of ~50k (market is crazy). I know I have to pay full capital gains on home two and have no problem with that reality. My tax accountant is convinced that the capital gains from home one affects the basis for home two so our capital gains on home two is ~130k instead of ~50k. I am not finding any rules that talk about this being the case. I've read through Pubs 530 and 523 and am still not getting what my accountant is talking about. I need some help understanding what he is talking about and the law behind it.