diff --git a/99_HIDDEN_functions.R b/99_HIDDEN_functions.R
index 7d5580d6c9b956953e4f86eaa756e739f469d469..0f7dfce1418bbe291eb2c7cd453c7b3f0de5b664 100644
--- a/99_HIDDEN_functions.R
+++ b/99_HIDDEN_functions.R
@@ -50,6 +50,11 @@ get.corXY <- function(comm, traits, trait.sel="all", stat=c("mantel", "RV", "pro
 
 #### Function 1b - CorXY bootstrap####
 get.corXY.bootstrap <- function(comm, traits, trait.sel="all", bootstrap=199){
+  ## caution
+  ## ALL columns with only 0-1 values are AUTOMATICALLY considered as asym.bin sensu FD:gowdis
+  ##get all columns with binary variables
+  binary.traits <- which( (traits %>% summarize_all(is.bin)) ==T) 
+  
   if(identical(trait.sel, "all")) {trait.sel <- 1:ncol(traits)}
   ii <- trait.sel
   lab.tmp <- paste(ii, collapse="_")
@@ -62,7 +67,7 @@ get.corXY.bootstrap <- function(comm, traits, trait.sel="all", bootstrap=199){
   #Calculate correlations on full data
   n.sites <- nrow(comm)
   n.species <- ncol(comm)
-  syn.out.tmp <- matrix.x(comm=comm, traits=traits[,ii,drop=F], scale=T)$matrix.X
+  syn.out.tmp <- matrix.x(comm=comm, traits=traits[,ii,drop=F], scale=T, asym.bin=binary.traits)$matrix.X
   W.beals <- as.data.frame(beals(comm, include=T, type=2))
   # permtute traits 
   index.traits <- lapply(1:(bootstrap+1), function(x){sample(1:n.species, replace=F)})
@@ -81,7 +86,8 @@ get.corXY.bootstrap <- function(comm, traits, trait.sel="all", bootstrap=199){
   for(b in 1:bootstrap){
     #RV.tmp <- RV.rtest(W.beals[index.bootstr[[b]],], as.data.frame(syn.out.tmp)[index.bootstr[[b]],])
     RD.tmp <- dcor(W.beals[index.bootstr[[b]],], as.data.frame(syn.out.tmp)[index.bootstr[[b]],])^2
-    syn.out.perm.tmp <- matrix.x(comm=comm, traits=traits[index.traits[[bootstrap]],ii,drop=F], scale=T)$matrix.X
+    syn.out.perm.tmp <- matrix.x(comm=comm, traits=traits[index.traits[[bootstrap]],ii,drop=F], 
+                                 scale=T, asym.bin=binary.traits)$matrix.X
     #RV.perm.tmp <- RV.rtest(W.beals[index.bootstr[[b]],], as.data.frame(syn.out.perm.tmp)[index.bootstr[[b]],])
     RD.perm.tmp <- dcor(W.beals[index.bootstr[[b]],], as.data.frame(syn.out.perm.tmp)[index.bootstr[[b]],])^2
     corXY <- rbind(corXY,
@@ -210,4 +216,7 @@ get.SES <- function(obs.df, perm.df, stat="RV") {
 
 
 
+## Cracked version of matrix.x from SYNCSA to account for asymmetric binary variables in gowdis
+
+