```\n    function stake(\n        uint256 amount_,\n        bytes calldata proof_\n    ) external nonReentrant requireInitialized updateRewards tryNewEpoch {\n// rest of code\n        uint256 userBalance = stakeBalance[msg.sender];\n        if (userBalance > 0) {\n            // Claim outstanding rewards, this will update the rewards per token claimed\n            _claimRewards();\n        } else {\n            // Initialize the rewards per token claimed for the user to the stored rewards per token\n          rewardsPerTokenClaimed[msg.sender] = rewardsPerTokenStored;\n        }\n\n        // Increase the user's stake balance and the total balance\n        stakeBalance[msg.sender] = userBalance + amount_;\n        totalBalance += amount_;\n\n        // Transfer the staked tokens from the user to this contract\n        stakedToken.safeTransferFrom(msg.sender, address(this), amount_);\n    }\n```\n