Fixed type mismatch error for `try` statemaents.
Used more treeCopy to replace setPos