making this more modular/testable still