chap 2 refactoring almost completed