refactor
dfs and astar