diff --git a/R/var.relations.R b/R/var.relations.R
index 9edc76ac185d37ba52dd50985ff02911d881ec03..f67f6441c8759053fe1614bd4a3e9ba137e76fbe 100644
--- a/R/var.relations.R
+++ b/R/var.relations.R
@@ -91,7 +91,7 @@ var.relations = function(x = NULL, y = NULL, num.trees = 500, type = "regression
         stop("Too much classes defined, classification might be the wrong choice")
       }
     }
-    if (type == "regression" && class(y) == "factor") {
+    if (type == "regression" && inherits(y, "factor")) {
       stop("use factor variable for y only for classification! ")
     }
 
diff --git a/R/var.relations.mfi.R b/R/var.relations.mfi.R
index 563fb2302823f289862ba62ee81330f7ca6b371d..043c9c45785ef59d8af914d83e3b5a31de9c2ffe 100644
--- a/R/var.relations.mfi.R
+++ b/R/var.relations.mfi.R
@@ -93,7 +93,7 @@ var.relations.mfi = function(x = NULL, y = NULL, num.trees = 500, type = "regres
         stop("Too much classes defined, classification might be the wrong choice")
       }
     }
-    if (type == "regression" && class(y) == "factor") {
+    if (type == "regression" && inherits(y, "factor")) {
       stop("use factor variable for y only for classification! ")
     }
 
diff --git a/R/variable_selection_mir.R b/R/variable_selection_mir.R
index 090826b6530d8da941d38d5490e9c079d5499add..f8ea84e7dcd4b6a133a79fee7e3ba7496ba1947f 100644
--- a/R/variable_selection_mir.R
+++ b/R/variable_selection_mir.R
@@ -110,7 +110,7 @@ var.select.mir = function(x = NULL, y = NULL, num.trees = 500, type = "regressio
         stop("Too much classes defined, classification might be the wrong choice")
       }
     }
-    if (type == "regression" && class(y) == "factor") {
+    if (type == "regression" && inherits(y, "factor")) {
       stop("use factor variable for y only for classification! ")
     }
 
diff --git a/R/variable_selection_smd.R b/R/variable_selection_smd.R
index 35d6508c6b458b537868c82dbefbc3a11b382279..ef239f06e1800ba076f4cb44b879d563d2ac6a7f 100644
--- a/R/variable_selection_smd.R
+++ b/R/variable_selection_smd.R
@@ -112,7 +112,7 @@ var.select.smd = function(x = NULL, y = NULL, num.trees = 500, type = "regressio
       stop("Too much classes defined, classification might be the wrong choice")
     }
   }
-  if (type == "regression" && class(y) == "factor") {
+  if (type == "regression" && inherits(y, "factor")) {
     stop("use factor variable for y only for classification! ")
   }
   data = data.frame(y, x)