Trying to fix infinite loop bug.