clamp function is wrong