Refactor of code - Chapter 7