fix forever-loop bug