TEST 0: move code to dfs_common