Optimized problem 4.