1. Debrief your failures
  2. That's it.
  3. Quitting a habit is not a single time effort, it's an ongoing process of getting to know yourself and your context.
  4. Every time you fail, write down what were you doing, feeling, or craving. And in which context it happened.
  5. You'll increasingly learn when you are the most vulnerable and what situations trigger this behavior the most.
  6. Then design strategies to prevent those circumstances (e.g. avoiding people/places or self-regulating with meditation)
  7. Soon enough you'll start acting differently, simply because your rewired yourself and your environment.