trying to fix infinite loop