some general refactoring