Added join and joinTree functions