Make the reverse algorithm works with quad and quadtri