reivse dfs, not test yet
revise temp saving