Added cycle detection
wip