Exercise 4 for DSN1678