fixed math for slice clamping