Use your original program as a reference for your new one. Compare what the first one is doing with what your current one is. The original code worked fine. You should be able to undo what you did to make the array back into a 1 dimensional array. (A regular array.)
Sorry I can't help you any further, it's late where I'm at and I need to get to bed.