Optimized Problem 39