Solution for exercise 2.1