Implemented exercise 2.