Solved exercises 20-26 from chapter 5