refactor to reduce duplication