rewrite DTree
tweaked
tweaked