Try a simpler algorithm for detecting cycles.