implements and satisfies test for exercise 5.
implements and satisfies test for exercise 6