All perfect praise be to Allaah, the Lord of the worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad, sallallaahu ‘alayhi wa sallam, is His slave and Messenger.
The Hadeeth you mentioned is not Saheeh, as stated by Ibn Al-Jawzi, Al-‘Ajlooni, ‘Ali Al-Qaari, Ar-Rahaawi and Al-Albaani . Masturbation, although impermissible, is less sinful than Zina (fornication/adultery) and anal intercourse. For Allaah The Almighty Says (what means): {And they who guard their private parts. Except from their wives or those their right hands possess, for indeed, they will not be blamed. But whoever seeks beyond that, then those are the transgressors.} [Quran 23:5-7]
Maalik, Ash-Shaafi‘i and other scholars deduced from this verse that masturbation is forbidden.
Therefore, you must abstain from masturbation, Zina and anal intercourse.