small optimization: don't evaluate contours if you already have a good solution.