This works but the code is horrible.  I need to clean it up but I should check in the working version first.