Small refactor to reduce duplication.