Corrected generation method. Trying to figure a way of displaying the tree