Added out of range check