Note: this pattern suggest that verses 21-22 are referring back to Balaam as a pre-eminent example of turning away from the way revealed by the Lord and ending up dead.
A. 15 Which have forsaken the right way, and are gone astray, following the way of Balaam the son of Bosor, who loved the wages of unrighteousness; 16 But was rebuked for his iniquity: the dumb ass speaking with man’s voice forbad the madness of the prophet.
B. 17 These are wells without water, clouds that are carried with a tempest; to whom the mist of darkness is reserved for ever.18 For when they speak great swelling words of vanity, they allure through the lusts of the flesh, through much wantonness, those that were clean escaped from them who live in error.
C. 19 While they promise them liberty, they themselves are the servants of corruption:
C’. for of whom a man is overcome, of the same is he brought in bondage.
B’. 20 For if after they have escaped the pollutions of the world through the knowledge of the Lord and Saviour Jesus Christ, they are again entangled therein, and overcome, the latter end is worse with them than these beginning.
A’. 21 For it had been better for them not to have known the way of righteousness, than, after they have known it, to turn from the holy commandment delivered unto them. 22 But it is happened unto them according to the true proverb, The dog is turned to his own vomit again; and the sow that was washed to her wallowing in the mire.