Implemented DFS, does not avoid cat