optimize problem 12