first cut at major refactor