SafeMath and Solidity 0.8.* handles overflows for basic math operations but not for casting.
Consider using OpenZeppelins SafeCast library to prevent unexpected overflows when casting from uint256 here:
