Describe a time when you had to work with a legacy codebase. How did you ensure your new code did not break existing functionality?