How would you approach refactoring a legacy method in a Java-based flight booking engine at Wego to improve maintainability?