hopefully fixing infinite loop bug.