Tweaking code and parameters for problem 3 but still not a good solution