solution for exercise 6.3