partway through refactoring more refactoring, works sort of now