added functionality to exercise 3