fix infinite loop bug
wip