Refactor

this is the code all in a single file.  not entirely done, but functional.