RE array index or dfs infinite recursiion