Added provision to detect contours