fix tree error with as.character