Minor refactoring: add helper function.