refactoring and examples