implementing dup
almost final version