[1.1.6] Refactor clamp function