attempt at refactor