bugfix and determineNonVarRegions function