Name shadowing

Previously the script had both a method and a local variable called
index that shadowed one another causing the script to fail.  This
change updates the name of the function so that it is no longer the
same as the local variable.