Adding an extra check

See if a certain piece of code is causing the index to be set to zero.