Refactoring for code reuse