You got it. And on a more broad level, knowing better but not doing is the root of all maladies.
And brings out questions about free will, agency, self-control, volition... and more.
These days I am fond of 2 books that actually touch on this very topic: "Grit" and "Ego is the enemy".