changed index to nonnegative integer