Exercises 2.27 - 2.29

Refactored exercise 2.18