added detecting-cycles