Fix bounds check error