A more elegant solution using detachCopy