problem 3 optimizations