fix fixTree function