fix cycle bug