I looked over the code and I can't see why it wouldn't work the last time either.
Have you tried looking at this with the debugger yet? I think break points after the 'PACK' and after the two arrays are build with SELECT would be ideal places to inspect tables and arrays to see what's going on.
Also try using this.value instead of this.displayvalue in the STORE statement.
"The Iron Fish: The water is cold...but the fish don't mind"
...Jay Jenks, boyhood chum