added deep copy of map to guard immutability of input.