“I acknowledged my sin unto thee, and mine iniquity have I not hid. I said, I will confess my transgressions unto the Lord; and thou forgavest the iniquity of my sin.”
— Psalm 32:5 (KJV)
When David finally stopped hiding his sin and confessed, God instantly forgave. Honesty with God always leads to freedom.