Added Model and partially Tree's logic