Implementing exercise 6-1 (untested)