Improved performance of contour algo