Added code for problem 3.6