Added the min max with recreating the tree every time