exercise 4 (parts 1-3)