problem 23
optimize