Fixed a possible endless loop bug