bounds check bug fix