No need for a loopIndex.
A bit more tidying...