a bit of general refactoring