Usually what makes people relapse after recovery (according to science) is being in the same situation, with the same people, as before when they were using their substance of choice. If you need to distance yourself from your friends to do that, then that's what you need to do for yourself. Easier said than done, I know, but it'll be worth it in the end.