sequential shape matching algorithm