huge code refactoring
dfs and search_node