more general refactoring