refactoring just a bit