Working on fixing the buildTree algorithm