```\nfunction withdraw(address depositor, IERC20 token, uint256 amountShares)\n    external\n    virtual\n    override\n    onlyWhenNotPaused(PAUSED\_WITHDRAWALS)\n    onlyStrategyManager\n{\n    require(token == underlyingToken, "StrategyBase.withdraw: Can only withdraw the strategy token");\n    // copy `totalShares` value to memory, prior to any decrease\n    uint256 priorTotalShares = totalShares;\n    require(\n        amountShares <= priorTotalShares,\n        "StrategyBase.withdraw: amountShares must be less than or equal to totalShares"\n    );\n\n    // Calculate the value that `totalShares` will decrease to as a result of the withdrawal\n    uint256 updatedTotalShares = priorTotalShares - amountShares;\n    // check to avoid edge case where share rate can be massively inflated as a 'griefing' sort of attack\n    require(updatedTotalShares >= MIN\_NONZERO\_TOTAL\_SHARES || updatedTotalShares == 0,\n        "StrategyBase.withdraw: updated totalShares amount would be nonzero but below MIN\_NONZERO\_TOTAL\_SHARES");\n    // Actually decrease the `totalShares` value\n    totalShares = updatedTotalShares;\n\n    /\*\*\n \* @notice calculation of amountToSend \*mirrors\* `sharesToUnderlying(amountShares)`, but is different since the `totalShares` has already\n \* been decremented. Specifically, notice how we use `priorTotalShares` here instead of `totalShares`.\n \*/\n    uint256 amountToSend;\n    if (priorTotalShares == amountShares) {\n        amountToSend = \_tokenBalance();\n    } else {\n        amountToSend = (\_tokenBalance() \* amountShares) / priorTotalShares;\n    }\n\n    underlyingToken.safeTransfer(depositor, amountToSend);\n}\n```\n