final refactoring on tutorial 7