Is that script on every template in the template repeater? If so, then you are doing as many for loops(and dataset conversions) as there are repeaters, consider using an expression bindings that use lookup on your source dataset instead. Manual Page.
Make 4 internal custom properties on your template, called displayName, min, max, target. Then, add an expression binding to each of those that follows the general format of lookup({sourceDataset}, {templateName.DataTypeID}, None, "dataID", "associatedDataColumnName").
A quick example for the displayName binding would be: lookup({[tagGroup]APITags/SOCValues 1}, {templateName.DataTypeID}, None, "dataID", "DataTypeName")
You then bind the text of the labels in your template to the respective internal template custom properties.