dfs + one extra check