Refactored map_values to be functional