Optimized problem 1