Add cycle detection in class example