Attempt at refactoring.