fixed contour indexing issue