```\nfunction updateTokenPriceIfApplicable() internal {\n    if (tokenPriceTimestamp != 0) {\n        uint timeElapsed = block.timestamp - tokenPriceTimestamp;\n\n        if (timeElapsed > priceUpdateTimeThreshold) {\n            uint tokenPriceCumulative = getCumulativeTokenPrice();\n\n            if (tokenPriceCumulativeLast != 0) {\n                tokenPrice = uint224((tokenPriceCumulative - tokenPriceCumulativeLast) / timeElapsed);\n            }\n\n            tokenPriceCumulativeLast = tokenPriceCumulative;\n            tokenPriceTimestamp = block.timestamp;\n        }\n    }\n}\n```\n