Starting over

So I started MFP in the beginning of the year, sticked to it for 3 weeks and lost about 6lbs which made me so so sooo happy. I avoided oily/fried food, food with really high calories, had many salad meals, and cut down my portion intake. I also did 30-40mins of stationary cycling at least 5 times a week. I was happy with my progress and determined to reach my goal weight until the other day when I went back to my hometown and had my bmi test in the gym. My weight went down but my fat mass went up and muscle mass went down. I was so depressed after that a part of me gave up on this diet plan. It's about 2 weeks since I did not follow my diet plan properly, I gained back about 4lbs and that really sucks. But now Im determined again to stick to my diet and reach my goal weight and would really appreciate it if I get some tips on how to improve on my diet and not give up again! :)