modified Exercise 7 to fix error