cleanup

implemented a single dfs function using an enum