Added code for exercise 4