Well, you are using way too much code! All you need is keep the 2D array in a shift regsiter of the FOR loop and use replace array subset to fill in the formatted data as you go. Try it!
You are also autoindexing on an arrau with a single element (180) forcing the FOR loop top stop after one iteration. use a scalar instead.