applied quick fix to stop rare infinite loop bug

applied quick fix to stop rare infinite loop bug