In Go 1.21, the standard library includes built-in max/min function, which can greatly simplify the code.