A Domain-Independent Algorithm for Plan Adaptation