pattern refactoring