first stab at refactor