think we have a working function.  Time to run the tests
Have to leave for the day.  need more debugging