A little common-purpose refactoring