Fixing the infinite loop caused by trying to count infinity