Added dfs algorithm