implements and satisfies test for exercise 8