```\nfunction _claimRewards(\n    address gauge,\n    address defaultToken,\n    address sendTo\n) internal returns (uint256[] memory amounts, address[] memory tokens) {\n    // rest of code \n\n    // Record balances before claiming\n    for (uint256 i = 0; i < totalLength; ++i) {\n        // The totalSupply check is used to identify stash tokens, which can\n        // substitute as rewardToken but lack a "balanceOf()"\n        if (IERC20(rewardTokens[i]).totalSupply() > 0) {\n            balancesBefore[i] = IERC20(rewardTokens[i]).balanceOf(account);\n        }\n    }\n\n    // Claim rewards\n    bool result = rewardPool.getReward(account, /*_claimExtras*/ true);\n    if (!result) {\n        revert RewardAdapter.ClaimRewardsFailed();\n    }\n\n    // Record balances after claiming and calculate amounts claimed\n    for (uint256 i = 0; i < totalLength; ++i) {\n        uint256 balance = 0;\n        // Same check for "stash tokens"\n        if (IERC20(rewardTokens[i]).totalSupply() > 0) {\n            balance = IERC20(rewardTokens[i]).balanceOf(account);\n        }\n\n        amountsClaimed[i] = balance - balancesBefore[i];\n\n        if (sendTo != address(this) && amountsClaimed[i] > 0) {\n            IERC20(rewardTokens[i]).safeTransfer(sendTo, amountsClaimed[i]);\n        }\n    }\n\n    RewardAdapter.emitRewardsClaimed(rewardTokens, amountsClaimed);\n\n    return (amountsClaimed, rewardTokens);\n}\n```\n