updated dismantling algorithm