Solved exercises 20 to 22