implemented exercise 3