My ugly code of DAG tracking algorithm realisation