attempt at shorter logic
fix logic of tree structure
Merge pull request #1 from bshur2008/newlogic

Newlogic