Brutally refactored code