should use Math.min as the specification says.