Use min and max for clamping