first cut of actual working code