Adding conditional logic to check for existing fields