colGroupHead.col[ referenceValuePosition ] should be cached outside the loop and the cached object should be used in the for and on line 346.