First feeble attempt at refactoring