Resolved
I have resolved this issue. The cause was in the loop index configuration.
The following code:
For[gxIndex = 1, gxIndex <= Length[gxValues], gxIndex++,
was replaced with:
For[gxIndex = statnum, gxIndex <= endnum, gxIndex++,
By properly setting statnum and endnum, the loop now correctly reflects the calculation range, and all patterns work as expected. I apologize for any confusion caused and hope this solution helps others facing a similar issue.