Added out of bounds check.