fixing tree construction