fixed bug when cycle occurs.