fix infinite loop