Solution for problem 10