refactoring design patterns