Solved exercises 3.16 to 3.23