use Math.min directly