Solution for Exercise 3