adding select tree function