solved problem 40