Implemented exercise 1 of chapter 3