refactoring map_array