finalize skeletonize algorithm