added logic to determine if it is a save or update