solved several dfs problems