more flailing around trying to make this clean and modularized