finish detecting cycles