Added DAG graph loop check