a small refactoring to make this more widely usable