fix infinite loop #415