fix infinite loop.