add cycle detection & termination in dfs fns to avoid SO
minor update select-with-bindings