Your question is Refactoring Legacy Code. Take a moment with it on the right.
Talk me through your thinking if you like. When you're confident, submit your answer and I'll grade it like a real screen (7/10 or better passes).
Describe a time when you had to refactor a complex piece of legacy code. How did you approach it, and what was the outcome? Explain how you assessed the risks, chose what to change first, and maintained system behavior while making the improvement. Include how you aligned teammates or stakeholders, validated the refactor, and measured the result.