Refactored code for updating values in hash with # of types.