Use a function to clamp to min/max