fix incorrect logic (infinite)