refactor.  unit tests working but app not working yet