Possibly fix infinite loop condition