exercise 5
exercise 6
cleaned up code