added check for existing value and updates