Fix index bounds check.