new working version  -- still lots of work to do