Fix weird infinite loop