partway through refactor w/marc's help