Solve endless loop bug.