clamp index value