How long have you been stuck with only losing 40 lbs? Plateaus happen. I’ve lost a total of about 70 lbs in the past year and hit multiple plateaus where there was no weight loss (for up to about a month!). I truly mean that, by the way, NO weight loss.
I weigh in every morning and I will sit within the same 1.5lb range for a month, and naturally it’s discouraging but all I can recommend is that you stick to it. I’d also reccomend possibly adding calories for a while. After getting down to 200 from 260 I hit what seemed like the plateau from hell and after that time I took an extended break from training and let go a lot on my diet.
After this break (a long one, about 4 months) I had put on some weight. However when losing that weight (after getting smart with my diet again and training) i soared past 200 lbs which previously was a plateau. Obviously you wouldn’t want to do what I did , take an extended break from lifting (or any break at all) but I do firmly believe that drastic changes in diet and the way you train can help with plateaus such as this.