fixed code to check when to add or update at the target system