A few years ago, I inherited a legacy codebase for a critical feature that was slowing down our development. The code was tangled and lacked clear structure, making bug fixes a nightmare. I started by writing comprehensive tests to cover existing functionality, which gave me confidence to refactor safely. Then, I broke down large functions into smaller, focused modules with clear responsibilities. I also improved naming conventions and removed redundant code. Throughout the process, I kept commits small and documented changes thoroughly to help the team follow along. My advice to others is to never refactor without solid test coverage and to tackle the code in manageable pieces rather than trying to fix everything at once. Patience and discipline in maintaining readability pay off by making the codebase easier to maintain and extend over time.