Index should start from zero, and the special case for zero can be removed.