Modified contraction and expansion algorythm