complete new revision of do_set.  Has bug(s)