Optimization of problem 10