Working on dfs algorithm