the code now works.  it can still be refactored some more but its a good start