updated for new version of tree + variabled tmp