refactored repetitive handling of output reassignments