mad refactoring