fix tiny infinite loop bug