```\n    function queueNewRewards(uint256 newRewards) external onlyWhitelisted {\n        uint256 startingQueuedRewards = queuedRewards;\n        uint256 startingNewRewards = newRewards;\n\n        newRewards += startingQueuedRewards;\n\n        if (block.number >= periodInBlockFinish) {\n            notifyRewardAmount(newRewards);\n            queuedRewards = 0;\n        } else {\n            uint256 elapsedBlock = block.number - (periodInBlockFinish - durationInBlock);\n            uint256 currentAtNow = rewardRate * elapsedBlock;\n            uint256 queuedRatio = currentAtNow * 1000 / newRewards;\n\n            if (queuedRatio < newRewardRatio) {\n                notifyRewardAmount(newRewards);\n                queuedRewards = 0;\n            } else {\n                queuedRewards = newRewards;\n            }\n        }\n\n        emit QueuedRewardsUpdated(startingQueuedRewards, startingNewRewards, queuedRewards);\n\n        // Transfer the new rewards from the caller to this contract.\n        IERC20(rewardToken).safeTransferFrom(msg.sender, address(this), newRewards);\n    }\n```\n