exercise 8, cleaned&revised