first cut at refactor for issue #11

incomplete & untested