diff --git a/Common/DataModel/vtkPiecewiseFunction.cxx b/Common/DataModel/vtkPiecewiseFunction.cxx
index 53dbfb140abb3de769de504576a1a6bdd72aac67..39eb8ecc3f3b7369adddb1911264c0ae035d5a28 100644
--- a/Common/DataModel/vtkPiecewiseFunction.cxx
+++ b/Common/DataModel/vtkPiecewiseFunction.cxx
@@ -1111,7 +1111,7 @@ void vtkPiecewiseFunction::SetCustomSearchMethod(int type)
     vtkGenericWarningMacro("enum out of scope, binary search will be applied");
 
     // set to binary search because it is the most general searchMethod
-    this->Internal->CustomSearchMethod = BINARY_SEARCH;
+    type = BINARY_SEARCH;
   }
 
   this->Internal->CustomSearchMethod = static_cast<SearchMethod>(type);