fix ring overrun check