modify make tree function now