Add guard to dfs/2