Fixed solution of exercise 3.11