Fix #2818. Last change didn't work, it needs to be one more step out of the loop.