fix infinite loop issue