```\n    while (_quantity > 0) {\n        Receipt memory deposit = deposits[i];\n        if (deposit.amount == 0) {\n            i++;\n            continue;\n        }\n        if (deposit.amount <= _quantity) {\n            // deposit amount is lesser than quantity use it fully\n            _quantity = _quantity - deposit.amount;\n            usdBalance[deposit.sender] -= deposit.amount;\n            amountToSend = (deposit.amount * 1e18) / _price;\n            IERC20(crab).transfer(deposit.sender, amountToSend);\n            emit USDCDeposited(deposit.sender, deposit.amount, amountToSend, i, 0);\n            delete deposits[i];\n            i++;\n        } else {\n            // deposit amount is greater than quantity; use it partially\n            deposits[i].amount = deposit.amount - _quantity;\n            usdBalance[deposit.sender] -= _quantity;\n            amountToSend = (_quantity * 1e18) / _price;\n            IERC20(crab).transfer(deposit.sender, amountToSend);\n            emit USDCDeposited(deposit.sender, _quantity, amountToSend, i, 0);\n            _quantity = 0;\n        }\n    }\n```\n