dup function duplicate an object.