Cleaning up the code.
Found error while cleaning up the code. Did count the wrong array and
did not copy from the correct array or to the correct array.