Re-factored the code to reduce duplication

previously, had a bunch of copy&pasted code around to parse the
multidimensional arrays, move that all into a single function to
reduce the clutter
added documentation to mapMultiDimArray

added the appropriate documentation for the method