Impossible to not lose weight fasting. If you are not losing weight on juice go to water only. You will lose weight.Also what is your current weight and height.
Gaining back 40 pounds is simply eating too much and not doing any exercise but exercise is not as effective as calorie restriction.Sounds like you need a better plan for once you are done fasting if you want to keep off the weight. Recommend aerobics of some type 5x week for 30 minutes or maybe up to hour depending on how much intensity you can do. Consider maybe some form of weights 3x week to 4x week.
And also you might want to look at ideas like EAT STOP EAT there is a website.
But seriously if you go on water and don't lose weight then you would have to have something hugely wrong with you. Other things to check are thyroid function.
Or maybe you need a new scale. And of course juice fasting is slower than water fasting.