RefactoringGeneric

Extract Method

Break a large function into smaller, focused pieces

Prompt

This function is too long and does too many things: [paste function] Refactor it by: 1. Identifying distinct responsibilities 2. Extracting each into a well-named method 3. Keeping the original function as a coordinator 4. Preserving all existing behavior — no functional changes Show me the refactored version with the extracted methods.