fix issue with infinite loop