problem 3 optimize