initial attempt at a refactor