It sounds like your doing everything right , so I don't know. It sounds like he is getting sooo close. Don't lose hope
I think you should take the treat outside with you so he knows he gets it for going potty outside and not for coming back into the house.
When we first got Chloe and she would have an accident , she knew she had did wrong ...so I would firmly say No.... then I would say
no treat and shake my head as we walked past the treats and I put her in her play yard while I cleaned up the spot. I swear she understood me....Not long after that if she had an accident she would wander by the treat jar and look at it ....and then look sad, like she knew
.
It just takes more time and patience than you think you even have.It sounds like your not far off , so hang in there.