diff --git a/README.md b/README.md
index f1fe845dfbf55baff5bc4ea87a0e9526095b5a91..c4bec13f2e2d6e9952d87e1617f11ebcc77b2828 100644
--- a/README.md
+++ b/README.md
@@ -36,14 +36,14 @@ This will create the executable binary file `req` that could be launched with th
 Launch _REQ_ without option to read the following documentation:
 
 ```
-  USAGE:  REQ <dfile> <tfile> [-v]
-
-  <dfile>  a distance matrice file  in either PHYLIP lower-
-           triangular or square format
-  <tfile>  an unrooted  binary phylogenetic  tree file with
-           no confidence value at branches in NEWICK format
-  -v       verbose mode
-
+ USAGE:  REQ  <dfile>  <tfile>  <outfile>  [-v]
+
+   <dfile>    distance matrix file in either PHYLIP lower-triangular or
+              square format
+   <tfile>    unrooted binary phylogenetic tree file with no confidence
+              value at branches in NEWICK format
+   <outfile>  outfile name
+   -v         verbose mode
 ```
 
 ## Example
@@ -54,7 +54,7 @@ The directory _example_ contains two files from the study of [Garcia-Hermoso et
 
 The following command line writes into the file _tree.req.t_ the phylogenetic tree from _example/tree.t_ with the rate of elementary quartets at each internal branch estimated from the distance matrix _example/matrix.d_:
 ```bash
-REQ  example/matrix.d  example/tree.t  >  tree.req.t
+REQ  example/matrix.d  example/tree.t  tree.req.t
 ```
 
 ## References
diff --git a/paper/paper.bib b/paper/paper.bib
new file mode 100644
index 0000000000000000000000000000000000000000..4217612634e4ba3520024ee3103c87ae75fb5d30
--- /dev/null
+++ b/paper/paper.bib
@@ -0,0 +1,299 @@
+@article{anisimova2006,
+    author = {Anisimova M and Gascuel O},
+    year = {2006},
+    title = {Approximate likelihood-ratio test for branches: a fast, accurate, and powerful alternative},
+    journal = {Systematic Biology},
+    volume = {55},
+    number = {4},
+    pages = {860--921},
+    doi = {10.1080/10635150600755453},
+    url = {https://doi.org/10.1080/10635150600755453}
+}
+
+@article{anisimova2011,
+    author = {Anisimova M and Gil M and Dufayard J-F and Dessimoz C and Gascuel O},
+    year = {2011},
+    title = {Survey of branch support methods demonstrates accuracy, power, and robustness of fast likelihood-based approximation schemes},
+    journal = {Systematic Biology},
+    volume = {60},
+    number = {5},
+    pages = {685--699},
+    doi = {10.1093/sysbio/syr041},
+    url = {https://doi.org/10.1093/sysbio/syr041}
+}
+
+@article{bremer1988,
+    author = {Bremer K},
+    year = {1988},
+    title = {The limits of amino acid sequence data in angiosperm phylogenetic reconstruction},
+    journal = {Evolution},
+    volume = {42},
+    number = {4},
+    pages = {795--803},
+    doi = {10.1111/j.1558-5646.1988.tb02497.x},
+    url = {https://doi.org/10.1111/j.1558-5646.1988.tb02497.x}
+}
+
+@article{bremer1994,
+    author = {Bremer K},
+    year = {1994},
+    title = {Branch support and tree stability},
+    journal = {Cladistics},
+    volume = {10},
+    number = {3},
+    pages = {295--304},
+    doi = {10.1111/j.1096-0031.1994.tb00179.x},
+    url = {https://doi.org/10.1111/j.1096-0031.1994.tb00179.x}
+}
+
+@inproceedings{buneman1971,
+    author = {Buneman P},
+    year = {1971},
+    title = {The recovery of trees from measures of dissimilarity},
+    booktitle= {Mathematics in Archaeological and Historical Sciences},
+    editor = {Hodson FR and Kendall DG and Tautu P},
+    pages = {387--395},
+    publisher = {Edinburgh University Press},
+    address = {Edimburgh},
+    url = {http://homepages.inf.ed.ac.uk/opb/homepagefiles/phylogeny-scans/manuscripts.pdf}
+}
+
+@article{chapus2005,
+    author = {Chapus C and Dufraigne C and Edwards S and Giron A and Fertil B and Deschavanne PJ},
+    year = {2005},
+    title = {Exploration of phylogenetic data using a global sequence analysis method},
+    journal = {BMC Evolutionary Biology},
+    volume = {5},
+    pages = {63},
+    doi = {10.1186/1471-2148-5-63},
+    url = {https://doi.org/10.1186/1471-2148-5-63}
+}
+
+@article{cohen2012,
+    author = {Cohen E and Chor B},
+    year = {2012},
+    title = {Detecting phylogenetic signals in eukaryotic whole genome sequences},
+    journal = {Journal of Computational Biology},
+    volume = {19},
+    number = {8},
+    pages = {945--956},
+    doi = {10.1089/cmb.2012.0122},
+    url = {https://doi.org/10.1089/cmb.2012.0122}
+}
+
+@article{desper2002,
+    author = {Desper R and Gascuel O},
+    year = {2002},
+    title = {Fast and accurate phylogeny reconstruction algorithms based on the minimum-evolution principle},
+    journal = {Journal of Computational Biology},
+    volume = {19},
+    number = {5},
+    pages = {687--705},
+    doi = {10.1089/106652702761034136},
+    url = {https://doi.org/10.1089/106652702761034136}
+}
+
+@article{felsenstein1985,
+    author = {Felsenstein J},
+    year = {1985},
+    title = {Confidence limits on phylogenies: an approach using the bootstrap},
+    journal = {Evolution},
+    volume = {39},
+    number = {4},
+    pages = {783--791},
+    doi = {10.1111/j.1558-5646.1985.tb00420.x},
+    url = {https://doi.org/10.1111/j.1558-5646.1985.tb00420.x}
+}
+
+@article{garcia2018,
+    author = {Garcia-Hermoso D and Criscuolo A and Lee SC and Legrand M and Chaouat M and Denis B and Lafaurie M and Rouveau M and Soler C and Schaal JV and Mimoun M and Mebazaa A and Heitman J and Dromer F and Brisse S and Bretagne S and Alanio A},
+    year = {2018},
+    title = {Outbreak of invasive wound mucormycosis in a burn unit due to multiple strains of Mucor circinelloides f. circinelloides resolved by whole-genome sequencing},
+    journal = {MBio},
+    volume = {9},
+    number = {2},
+    pages = {e00573-18},
+    doi = {10.1128/mBio.00573-18},
+    url = {http://mbio.asm.org/content/9/2/e00573-18}
+}
+
+@article{gascuel1997,
+    author = {Gascuel O},
+    year = {1997},
+    title = {BIONJ: an improved version of the NJ algorithm based on a simple model of sequence data},
+    journal = {Molecular Biology and Evolution},
+    volume = {14},
+    number = {7},
+    pages = {685--695},
+    doi = {10.1093/oxfordjournals.molbev.a025808},
+    url = {https://doi.org/10.1093/oxfordjournals.molbev.a025808}
+}
+
+@article{henz2005,
+    author = {Henz SR and Huson DH and Auch AF and Nieselt-Struwe K and Schuster SC},
+    year = {2005},
+    title = {Whole-genome prokaryotic phylogeny},
+    journal = {Bioinformatics},
+    volume = {21},
+    number = {10},
+    pages = {2329--2335},
+    doi = {10.1093/bioinformatics/bth324},
+    url = {https://doi.org/10.1093/bioinformatics/bth324}
+}
+
+@article{hoang2018a,
+    author = {Hoang DT and Chernomor O and von Haeseler A and Minh BQ and Vinh LS},
+    year = {2018},
+    title = {UFBoot2: improving the ultrafast bootstrap approximation},
+    journal = {Molecular Biology and Evolution},
+    volume = {35},
+    number = {2},
+    pages = {518--522},
+    doi = {10.1093/molbev/msx281},
+    url = {https://doi.org/10.1093/molbev/msx281}
+}
+
+@article{hoang2018b,
+    author = {Hoang DY and Vinh LS and Flouri T and Stamatakis A and von Haeseler A and Minh BQ},
+    year = {2018},
+    title = {MPBoot: fast phylogenetic maximum parsimony tree inference and bootstrap approximation},
+    journal = {BMC Evolutionary Biology},
+    volume = {18},
+    number = {1},
+    pages = {11},
+    doi = {10.1186/s12862-018-1131-3},
+    url = {https://doi.org/10.1186/s12862-018-1131-3}
+}
+
+@article{house2014,
+    author = {House CH and Pellegrini M and Fitz-Gibbon ST},
+    year = {2014},
+    title = {Genome-wide gene order distances support clustering the gram-positive bacteria},
+    journal = {Frontiers in Microbiology},
+    volume = {5},
+    pages = {785},
+    doi = {10.3389/fmicb.2014.00785},
+    url = {https://dx.doi.org/10.3389%2Ffmicb.2014.00785}
+}
+
+@article{krajewski1990,
+    author = {Krajewski C and Dickerman AW},
+    year = {1990},
+    title = {Bootstrap analysis of phylogenetic trees derived from DNA hydridization distances},
+    journal = {Systematic Zoology},
+    volume = {39},
+    number = {4},
+    pages = {383--390},
+    doi = {10.2307/2992358},
+    url = {https://doi.org/10.2307/2992358}
+}
+
+@article{lemoine2018,
+    author = {Lemoine F and Domelevo-Entfellner J-B and Wilkinson E and Correia D and Davila Felipe M and De Oliveira T and Gascuel O},
+    year = {2018},
+    title = {Renewing Felsenstein's phylogenetic bootstrap in the era of big data},
+    journal = {Nature},
+    volume = {556},
+    number = {7702},
+    pages = {452--456},
+    doi = {10.1038/s41586-018-0043-0 },
+    url = {http://dx.doi.org/10.1038/s41586-018-0043-0}
+}
+
+@article{makarenkov2010,
+    author = {Makarenkov V and Boc A and Xie J and Peres-Neto P and Lapointe F-J and Legendre P},
+    year = {2010},
+    title = {Weighted bootstrapping: a correction method for assessing the robustness of phylogenetic trees},
+    journal = {BMC Evolutionary Biology},
+    volume = {10},
+    pages = {250},
+    doi = {10.1186/1471-2148-10-250},
+    url = {https://doi.org/10.1186/1471-2148-10-250}
+}
+
+@article{minh2013,
+    author = {Minh BQ and Nguyen MA and von Haeseler A},
+    year = {2013},
+    title = {Ultrafast approximation for phylogenetic bootstrap},
+    journal = {Molecular Biology and Evolution},
+    volume = {30},
+    number = {5},
+    pages = {1188--1195},
+    doi = {10.1093/molbev/mst024},
+    url = {https://doi.org/10.1093/molbev/mst024}
+}
+
+@incollection{pardi2016,
+    author = {Pardi F and Gascuel O},
+    year = {2016},
+    title = {Distance-based methods in phylogenetics},
+    booktitle = {Encyclopedia of Evolutionary Biology},
+    editor = {Kliman R},
+    publisher = {Academic Press},
+    pages = {458--465},
+    url = {https://hal-lirmm.ccsd.cnrs.fr/lirmm-01386569}
+}
+
+@article{saitou1987,
+    author = {Saitou N and Nei M},
+    year = {1987},
+    title = {The neighbor-joining method: a new method for reconstructing phylogenetic trees},
+    journal = {Molecular Biology and Evolution},
+    volume = {4},
+    number = {4},
+    pages = {406--425},
+    doi = {10.1093/oxfordjournals.molbev.a040454},
+    url = {https://doi.org/10.1093/oxfordjournals.molbev.a040454}
+}
+
+@article{spencer2007,
+    author = {Spencer M and Bryant D and Susko E},
+    year = {2007},
+    title = {Conditioned genome reconstruction: how to avoid choosing the conditioning genome},
+    journal = {Systematic Biology},
+    volume = {56},
+    number = {1},
+    pages = {25--43},
+    doi = {10.1080/10635150601156313},
+    url = {https://doi.org/10.1080/10635150601156313}
+}
+
+@article{studier1988,
+    author = {Studier JA and Kepler KJ},
+    year = {1988},
+    title = {A note on the neighbour-joining method of Saitou and Nei},
+    journal = {Molecular Biology and Evolution},
+    volume = {5},
+    number = {1},
+    pages = {729--731},
+    doi = {10.1080/10635150601156313},
+    url = {https://doi.org/10.1080/10635150601156313}
+}
+
+@article{wang2006,
+    author = {Wang LS and Warnow T and Moret BM and Jansen RK and Raubeson LA},
+    year = {2006},
+    title = {Distance-based genome rearrangement phylogeny},
+    journal = {Journal of Molecular Evolution},
+    volume = {63},
+    number = {4},
+    pages = {473--483},
+    doi = {10.1007/s00239-005-0216-y},
+    url = {https://doi.org/10.1007/s00239-005-0216-y}
+}
+
+@article{zaretskii1965,
+    author = {Zaretskii ZA},
+    year = {1965},
+    title = {ПОСТРОЕНИЕ ДЕРЕВА ПО НАБОРУ РАССТОЯНИЙ МЕЖДУ ВИСЯЧИМИ ВЕРШИНАМИ},
+    note = {(Constructing a tree on the basis of a set of distances between the hanging vertices; in Russian)},
+    journal = {Uspekhi Matematicheskikh Nauk},
+    volume = {20},
+    number = {6},
+    pages = {94--96},
+    url = {http://mi.mathnet.ru/eng/umn6134}
+}
+
+
+
+ 
diff --git a/paper/paper.md b/paper/paper.md
new file mode 100644
index 0000000000000000000000000000000000000000..236e12e9a7a02044603cff3c35f260b720daf9dd
--- /dev/null
+++ b/paper/paper.md
@@ -0,0 +1,30 @@
+---
+title: 'REQ: assessing branch supports of a distance-based phylogenetic tree with the rate of elementary quartets'
+tags:
+  - phylogenetics
+  - branch support
+  - evolutionary distances
+  - quartets
+  - Java
+authors:
+  - name: Alexis Criscuolo
+    orcid: 0000-0002-8212-5215
+    affiliation: 1
+affiliations:
+ - name: Institut Pasteur – Bioinformatics and Biostatistics Hub – C3BI, USR 3756 IP CNRS – 25-28 Rue du Docteur Roux, 75015 Paris, France
+   index: 1
+date: 13 July 2018
+bibliography: paper.bib
+---
+
+# Summary
+
+``REQ`` is a program for quickly estimating a confidence value at each branch of a distance-based phylogenetic tree. Branch support assessment is commonly based on bootstrap procedures [@felsenstein1985; @makarenkov2010; @lemoine2018]. Unfortunately, as they are based on numerous resampling of aligned characters, such procedures require long running times, despite some recent advances [@minh2013; @hoang2018a; @hoang2018b]. In fact, direct branch support methods were already developed for character-based approaches that optimize maximum-parsimony or maximum-likelihood criteria, in order to achieve faster running times [@bremer1988; @bremer1994; @anisimova2006; @anisimova2011]. However, to our knowledge, no practical implementation of direct branch support methods is currently available for distance-based approaches.
+
+Distance-based approaches proceed in two steps: a pairwise evolutionary distance is estimated between each pair of (biological) objects, and, next, an algorithm is used to infer the tree with branch lengths that best fits the evolutionary distance matrix [@pardi2016]. Because of their speed, distance-based methods are widely used for inferring phylogenetic trees. Moreover, as such algorithms only need a distance matrix, they allow phylogenetic analyses to be carried out from a wide range of data types, e.g. DNA-DNA hybridization experiments [krajewski1990], gene orders [@wang2006; @house2014], gene content [@spencer2007], or unaligned genome sequences [@chapus2005; @henz2005; @cohen2012; @garcia2018]. Nevertheless, in such cases, standard bootstrap-based methods can not be used for estimating branch confidence values. 
+
+In order to fill this void, the program ``REQ`` was developed. This tool estimates the rate of elementary quartets (REQ) for each branch of a given phylogenetic tree from the associated distance matrix, as described by [@guenoche2001]. This method simply computes the proportion of four-leaf subtrees (i.e. quartets) induced by every internal branch that are supported by the four-point condition applied to the six corresponding pairwise evolutionary distances [@zaretskii1965; @buneman1971]. Therefore, this measure is not based on a random sampling (such as bootstrap-based confidence supports). The closer this measure is to 1, the more the corresponding branch is fully supported by the pairwise evolutionary distances.
+
+The program ``REQ`` is available on [GitLab](https://gitlab.pasteur.fr/GIPhy/REQ) under the [licence GNU GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html). Implemented in Java, ``REQ`` could be used on every operating system with a simple command line. ``REQ`` only needs two input files: a distance matrix file in either PHYLIP lower-triangular or square format, and a phylogenetic tree file in NEWICK format created from the distance matrix by any standard phylogenetic tree reconstruction method, e.g. neighbor-joining [@saitou1987; @studier1988], BioNJ [@gascuel1997], FastME [@desper2002]. Although computing the REQ value for every branch of a phylogenetic tree on *n* leaves requires *O*(*n*<sup>5</sup>) time complexity, ``REQ`` running time is quite fast (e.g. ~5 seconds with *n* = 500 on a standard computer) and could therefore be used with large phylogenetic trees.
+
+# References
diff --git a/src/REQ.java b/src/REQ.java
index 37298d3840fa3a73340aa6fa93812e06773a584d..764f751f095f229c5b26af5181e5ed1f45868c68 100644
--- a/src/REQ.java
+++ b/src/REQ.java
@@ -35,10 +35,12 @@ import java.text.*;
 public class REQ {
 
     // constants
+    final static String VERSION = "v1.2.180713ac";
     final static int INF = Integer.MAX_VALUE;
     
     // io
     static BufferedReader in;
+    static BufferedWriter out;
     static boolean verbose;
     static NumberFormat df;
 
@@ -46,11 +48,11 @@ public class REQ {
     static int n;
     static ArrayList<String> lbl;
     static float[][] dm;
-    static StringBuilder nwk, tr;
+    static StringBuilder nwk, tr, tro;
 
     // stuffs
-    static int i, j, m, u, v, w, x, y, up, dn, last;
-    static double re, ab, ac, bc, abcd;
+    static int i, j, m, u, v, w, x, y, last, sup;
+    static double re, ab, ac, bc, abcd, up, dn;
     static short si;
     static String line;
     static String[] split;
@@ -61,23 +63,25 @@ public class REQ {
     public static void main(String[] args) throws IOException {
 
 	//### man ############################################################################################################################################################################
-	if ( args.length < 2 ) {
+	if ( args.length < 3 ) {
 	    System.out.println("");
-	    System.out.println("  USAGE:  REQ <dfile> <tfile> [-v]");
+	    System.out.println(" USAGE:  REQ  <dfile>  <tfile>  <outfile>  [-v]");
 	    System.out.println("");
-	    System.out.println("  <dfile>  a distance matrice file  in either PHYLIP lower-");
-	    System.out.println("           triangular or square format");
-	    System.out.println("  <tfile>  an unrooted  binary phylogenetic  tree file with");
-	    System.out.println("           no confidence value at branches in NEWICK format");
-	    System.out.println("  -v       verbose mode");
+	    System.out.println("   <dfile>    distance matrix file in either PHYLIP lower-triangular or");
+	    System.out.println("              square format");
+	    System.out.println("   <tfile>    unrooted binary phylogenetic tree file with no confidence");
+	    System.out.println("              value at branches in NEWICK format");
+	    System.out.println("   <outfile>  outfile name");
+	    System.out.println("   -v         verbose mode");
 	    System.out.println("");
 	    System.exit(0);
 	}
 
 	//### init ###########################################################################################################################################################################
         df = NumberFormat.getNumberInstance(Locale.US); df.setGroupingUsed(false); df.setMaximumFractionDigits(3); df.setMinimumFractionDigits(3);
-	verbose = false; if ( args.length > 2 ) verbose = true;
-	
+	verbose = ( (args.length > 3) && args[3].equals("-v") ) ? true : false;
+	if ( verbose ) System.out.println("REQ " + VERSION);
+		
 	//### reading distance matrix dm #####################################################################################################################################################
 	in = new BufferedReader(new FileReader(new File(args[0])));
 	while ( true ) try { if ( (line=in.readLine().trim()).length() != 0 ) break; } catch ( NullPointerException e ) { System.out.println("matrix file is empty"); System.exit(1); }
@@ -86,7 +90,7 @@ public class REQ {
 	lbl = new ArrayList<String>(n); dm = new float[n][]; i = -1;
 	while ( true ) {
 	    try { line = in.readLine().trim(); } catch ( NullPointerException e ) { in.close(); break; }
-	    split = line.split("\\s+"); lbl.add(split[0]); dm[++i] = new float[i]; j = 0; while ( ++j <= i ) dm[i][--j] = (float) Double.parseDouble(split[++j]);
+	    split = line.split("\\s+"); lbl.add(split[0]); dm[++i] = new float[i]; j = 0; while ( ++j <= i ) dm[i][--j] = Float.parseFloat(split[++j]);
 	}
 	if ( ++i != n ) { System.out.println("matrix file is incorrectly formatted"); System.exit(1); }
 	
@@ -98,7 +102,7 @@ public class REQ {
 	//### discarding branch lengths from tr ##############################################################################################################################################
 	//u = -1; while ( (u=tr.indexOf(":", ++u)) != -1 ) { x = ( (x=tr.indexOf(",", u)) != -1 ) ? x : INF; y = ( (y=tr.indexOf(")", u)) != -1 ) ? y : INF; tr = tr.delete(u, (x<y)?x:y); }
 	u = -1 ; while ( (u=tr.indexOf(":", ++u)) != -1 ) tr = tr.delete(u, (x=((x=tr.indexOf(",",u))!=-1)?x:INF) < (y=((y=tr.indexOf(")",u))!=-1)?y:INF) ? x : y);
-
+	
 	//### encoding lbl within tr #########################################################################################################################################################
 	u = -1;
 	while ( (u = (x=((x=tr.indexOf(",",u))!=-1)?x:INF) < (y=((y=tr.indexOf("(",u))!=-1)?y:INF) ? x : y) < INF ) {
@@ -106,27 +110,39 @@ public class REQ {
 	    tr = tr.replace(u, (v = (x=((x=tr.indexOf(",",u))!=-1)?x:INF) < (y=((y=tr.indexOf(")",u))!=-1)?y:INF) ? x : y), String.valueOf(j=lbl.indexOf(tr.substring(u, v))));
 	    if ( j == -1 ) { System.out.println(tr.substring(u, v) + " is not inside distance matrix"); System.exit(1); }
 	}
+	if ( verbose ) System.out.println("# " + tr.toString());
+	    
+	//### estimating the rate of EQ re for each internal branch e ########################################################################################################################
+	tro = new StringBuilder(tr.toString());	
+	//# first tr rooting:   ((ST1),(ST2),(ST3));  =>  (((ST1),(ST2)),(ST3));  ###############################################################
+	//#                                                            |      |
+	//#                                                           sup    last
+	tr = tr.insert(0, '('); sup = apc(tr, tr.lastIndexOf(")")); tr = tr.insert(sup, ')'); //# NOTE: closing parenthesis at index 'sup' should not be considered for REQ calculations
+	last = tr.lastIndexOf(")"); 
+	if ( verbose ) { i = -1; while ( ++i < n ) System.out.println(i + ": " + lbl.get(i)); System.out.println("# " + tr.toString()); }
 
-	//### rooting tr #####################################################################################################################################################################
-	tr = tr.insert(0, '('); last = apc(tr, tr.lastIndexOf(")")); tr = tr.insert(last, ')'); // closing parenthesis at index 'last' should not be considered for EWDQ calculations
-	if ( verbose ) { i = -1; while ( ++i < n ) System.out.println(i + ": " + lbl.get(i)); System.out.println(tr.toString()); }
-
-	//### estimating the rate of EWDQ re for each internal branch e ######################################################################################################################
 	ts = new TreeSet<Short>(); si = 0; --si; while ( ++si < n ) ts.add(new Short(si)); are = new ArrayList<Double>(); u = -1;
 	while ( (u=tr.indexOf(")", ++u)) != last ) {
-	    //# parsing every internal branch e at index u in order to obtain  lbl(STa) lbl(STb) | lbl(STc) lbl(T)-lbl(STa U STb U STc)  ###########################################
+	    //# second tr rooting:   ((ST1),(ST2),(ST3));  =>  ((ST1),((ST2),(ST3)));  ##########################################################
+	    //#                                                             |     |
+	    //#                                                             u    last
+	    if ( u == sup ) {
+		last = tro.lastIndexOf(")"); tr = tro.insert(last, ')'); v = apc(tr, apc(tr, last)); tr = tr.insert(++v, '(');
+		++last; //# NOTE: closing parenthesis at index 'last' should not be considered for REQ calculations
+		if ( verbose ) System.out.println("# " + tr.toString());
+		sup = 0; --u; continue;
+	    }
+	    //# parsing every internal branch e at index u in order to obtain  lbl(STa) lbl(STb) | lbl(STc) lbl(T)-lbl(STa U STb U STc)  ########
 	    //#    ( ... (((STa),(STb)),STc) ... );
 	    //#          ||     |     |    |
 	    //#          xv     w    'u'   y
 	    v = aop(tr, u); w = apc(tr, u); x = cop(tr, u); y = ccp(tr, u); stdts = new TreeSet<Short>(ts);
-	    //System.out.print(u + ":  " + tr.substring(v+1,w) + "  " + tr.substring(w+1,u) + "  " + ((u+1!=y)?tr.substring(u+2,y):tr.substring(x+1,v-1)) + "   " );
 	    sta = new short[j=(split=tr.substring(v+1, w).replaceAll("[,\\(\\)]+", " ").trim().split(" ")).length]; for (String s: split) stdts.remove(Short.valueOf(sta[--j]=Short.parseShort(s)));
 	    stb = new short[j=(split=tr.substring(++w, u).replaceAll("[,\\(\\)]+", " ").trim().split(" ")).length]; for (String s: split) stdts.remove(Short.valueOf(stb[--j]=Short.parseShort(s)));
 	    stc = new short[j=(split=((u+1 != y) ? tr.substring(u+2, y) : tr.substring(++x, --v)).replaceAll("[,\\(\\)]+", " ").trim().split(" ")).length]; for (String s: split) stdts.remove(Short.valueOf(stc[--j]=Short.parseShort(s)));
 	    std = new short[j=stdts.size()]; for (Short si: stdts) std[--j] = si.shortValue();
-	    //# comparing every quartet ab|cd with the topology induced by dm, where a,b,c,d belongs to STa,STb,STc,STd, respectively  #############################################
-	    //Arrays.sort(sta); Arrays.sort(stb); Arrays.sort(stb); 
-	    up = 0;
+	    //# comparing every quartet ab|cd with the topology induced by dm, where a,b,c,d belongs to STa,STb,STc,STd, respectively  ##########
+	    up = 0; //Arrays.sort(sta); Arrays.sort(stb); Arrays.sort(stb); 
 	    for (short a: sta) {
 		for (short b: stb) { ab = (a>b)?dm[a][b]:dm[b][a];
 		    for (short c: stc) { ac = (a>c)?dm[a][c]:dm[c][a]; bc = (b>c)?dm[b][c]:dm[c][b];
@@ -134,18 +150,15 @@ public class REQ {
 		    }
 		}
 	    }
-	    //# storing re value inside are ########################################################################################################################################
-	    are.add(Double.valueOf(re=up/(double)(dn=sta.length*stb.length*stc.length*std.length)));
-	    if ( verbose ) System.out.println((Arrays.toString(sta) + Arrays.toString(stb) + Arrays.toString(stc) + Arrays.toString(std)).replaceAll(" ","") + " Re=" + df.format(re) + " (" + up + "/" + dn + ")");
+	    //# storing re value inside are #####################################################################################################
+	    are.add(Double.valueOf(re=up/(dn=((double)sta.length)*((double)stb.length)*stc.length*std.length)));
+	    if ( verbose ) System.out.println((Arrays.toString(sta) + Arrays.toString(stb) + Arrays.toString(stc) + Arrays.toString(std)).replaceAll(" ","") + " Re=" + df.format(re) + " (" + ((long)up) + "/" + ((long)dn) + ")");
 	}
 
 	//### writing re values into nwk #####################################################################################################################################################
-	u = -1; v = -1;
-	while ( (u=nwk.indexOf(")", ++u)) != -1 ) {
-	    if ( nwk.charAt(u+1) == ';' ) break;
-	    nwk = nwk.insert(u+1, df.format(are.get(++v).doubleValue()));
-	}
-	System.out.println(nwk.toString());	
+	u = -1; v = -1; while ( (u=nwk.indexOf(")", ++u)) != -1 ) { if ( nwk.charAt(u+1) == ';' ) break; nwk = nwk.insert(u+1, df.format(are.get(++v).doubleValue())); }
+	out = new BufferedWriter(new FileWriter(new File(args[2]))); out.write(nwk.toString()); out.close(); //System.out.println(nwk.toString());
+	if ( verbose ) System.out.println("output tree written into " + args[2]);
     }
 
     //## containing opening parenthesis (cop): returns x from t and i, where i is a closing parenthesis index