Fix overshoot on bounds check