Solution for problem 5 added