The line beginning with "if(parts != 3 || " makes the complete function senseless, because there are only 2 parts (deleted by '_')!
So the correct line should look as follows instead:
"if(parts != 2 || StringFind(variableNameParts[0], getVariablePrefix()) != 0) continue;"