Solved exercises 5.1 to 5.3